Files
maher 511fad8199
Build / run (push) Has been cancelled
Initial commit
2026-05-14 13:42:10 +02:00

38 lines
961 B
PHP
Executable File

<?php
namespace Database\Seeders;
use App\Models\Channel;
use App\Models\User;
use Illuminate\Database\Seeder;
class WatchlistSeeder extends Seeder
{
/**
* Create watchlist for users that don't already have one.
*/
public function run(): void
{
$userIds = app(User::class)
->whereDoesntHave('watchlist')
->pluck('id');
$userIds->each(function($userId) {
Channel::create([
'name' => 'watchlist',
'user_id' => $userId,
'internal' => true,
'public' => false,
'type' => 'list',
'config' => [
'contentType' => 'manual',
'contentOrder' => 'channelables.order:asc',
'contentModel' => 'title',
'layout' => 'grid',
'preventDeletion' => true,
]
]);
});
}
}