We don’t need the complexity of S3. Sepcifically the complexity of managing my own AWS account, flysystem made the Laravel side easy. A command is added to copy the the S3 files over to local storage.
48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\Like;
|
|
use Faker\Generator;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class LikesTableSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Seed the likes table.
|
|
*
|
|
* @psalm-suppress PossiblyUnusedMethod
|
|
*/
|
|
public function run(): void
|
|
{
|
|
Like::factory(10)->create();
|
|
|
|
$now = Carbon::now()->subDays(rand(3, 6));
|
|
$faker = new Generator;
|
|
$faker->addProvider(new \Faker\Provider\en_US\Person($faker));
|
|
$faker->addProvider(new \Faker\Provider\Lorem($faker));
|
|
$faker->addProvider(new \Faker\Provider\Internet($faker));
|
|
$likeFromAuthor = Like::create([
|
|
'url' => $faker->url,
|
|
'author_url' => $faker->url,
|
|
'author_name' => $faker->name,
|
|
]);
|
|
DB::table('likes')
|
|
->where('id', $likeFromAuthor->id)
|
|
->update([
|
|
'created_at' => $now->toDateTimeString(),
|
|
'updated_at' => $now->toDateTimeString(),
|
|
]);
|
|
|
|
$now = Carbon::now()->subHours(rand(3, 6));
|
|
$likeJustUrl = Like::create(['url' => 'https://example.com']);
|
|
DB::table('likes')
|
|
->where('id', $likeJustUrl->id)
|
|
->update([
|
|
'created_at' => $now->toDateTimeString(),
|
|
'updated_at' => $now->toDateTimeString(),
|
|
]);
|
|
}
|
|
}
|