2020-11-14 16:57:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Database\Factories;
|
|
|
|
|
|
|
|
use App\Models\User;
|
2024-01-12 14:41:02 +00:00
|
|
|
use App\Values\SmartPlaylistRule;
|
|
|
|
use App\Values\SmartPlaylistRuleGroup;
|
|
|
|
use App\Values\SmartPlaylistRuleGroupCollection;
|
2020-11-14 16:57:25 +00:00
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
2024-01-12 14:41:02 +00:00
|
|
|
use Illuminate\Support\Str;
|
2020-11-14 16:57:25 +00:00
|
|
|
|
|
|
|
class PlaylistFactory extends Factory
|
|
|
|
{
|
2020-12-22 20:11:22 +00:00
|
|
|
/** @return array<mixed> */
|
2020-11-14 16:57:25 +00:00
|
|
|
public function definition(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'user_id' => User::factory(),
|
|
|
|
'name' => $this->faker->name,
|
|
|
|
'rules' => null,
|
|
|
|
];
|
|
|
|
}
|
2024-01-12 14:41:02 +00:00
|
|
|
|
|
|
|
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'],
|
|
|
|
]),
|
|
|
|
],
|
|
|
|
]),
|
|
|
|
]),
|
|
|
|
]);
|
|
|
|
}
|
2020-11-14 16:57:25 +00:00
|
|
|
}
|