mirror of
https://github.com/koel/koel
synced 2024-12-11 05:02:27 +00:00
45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Playlist;
|
|
use App\Models\User;
|
|
use App\Values\SmartPlaylistRule;
|
|
use App\Values\SmartPlaylistRuleGroup;
|
|
use App\Values\SmartPlaylistRuleGroupCollection;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
class PlaylistFactory extends Factory
|
|
{
|
|
protected $model = Playlist::class;
|
|
|
|
/** @return array<mixed> */
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'user_id' => User::factory(),
|
|
'name' => $this->faker->name,
|
|
'rules' => null,
|
|
];
|
|
}
|
|
|
|
public function smart(): static
|
|
{
|
|
return $this->state(fn () => [ // @phpcs:ignore
|
|
'rules' => SmartPlaylistRuleGroupCollection::create([
|
|
SmartPlaylistRuleGroup::make([
|
|
'id' => Str::uuid()->toString(),
|
|
'rules' => [
|
|
SmartPlaylistRule::make([
|
|
'id' => Str::uuid()->toString(),
|
|
'model' => 'artist.name',
|
|
'operator' => 'is',
|
|
'value' => ['foo'],
|
|
]),
|
|
],
|
|
]),
|
|
]),
|
|
]);
|
|
}
|
|
}
|