2017-10-10 15:58:07 +01:00
|
|
|
<?php
|
|
|
|
|
2020-10-17 17:15:06 +01:00
|
|
|
namespace Database\Seeders;
|
|
|
|
|
2019-07-26 10:40:56 +01:00
|
|
|
use Illuminate\Support\Carbon;
|
2017-12-22 14:28:41 +00:00
|
|
|
use App\Models\{Bookmark, Tag};
|
2017-10-10 15:58:07 +01:00
|
|
|
use Illuminate\Database\Seeder;
|
2019-07-26 10:40:56 +01:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2017-10-10 15:58:07 +01:00
|
|
|
|
|
|
|
class BookmarksTableSeeder extends Seeder
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the database seeds.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function run()
|
|
|
|
{
|
2020-10-17 17:15:06 +01:00
|
|
|
Bookmark::factory(10)->create();
|
2017-12-22 14:28:41 +00:00
|
|
|
factory(Bookmark::class, 10)->create()->each(function ($bookmark) {
|
|
|
|
$bookmark->tags()->save(factory(Tag::class)->make());
|
2019-07-26 10:40:56 +01:00
|
|
|
|
|
|
|
$now = Carbon::now()->subDays(rand(2, 12));
|
|
|
|
DB::table('bookmarks')
|
|
|
|
->where('id', $bookmark->id)
|
|
|
|
->update([
|
|
|
|
'created_at' => $now->toDateTimeString(),
|
|
|
|
'updated_at' => $now->toDateTimeString(),
|
|
|
|
]);
|
2017-10-11 16:28:56 +01:00
|
|
|
});
|
2017-10-10 15:58:07 +01:00
|
|
|
}
|
|
|
|
}
|