koel/database/factories/SongFactory.php

34 lines
971 B
PHP
Raw Normal View History

<?php
namespace Database\Factories;
use App\Models\Album;
use App\Models\Song;
use Illuminate\Database\Eloquent\Factories\Factory;
class SongFactory extends Factory
{
protected $model = Song::class;
2020-12-22 20:11:22 +00:00
/** @return array<mixed> */
public function definition(): array
{
/** @var Album $album */
$album = Album::factory()->create();
return [
'album_id' => $album->id,
'artist_id' => $album->artist->id,
2021-07-26 21:21:36 +00:00
'title' => $this->faker->sentence,
'length' => $this->faker->randomFloat(2, 10, 500),
'track' => random_int(1, 20),
'disc' => random_int(1, 5),
'lyrics' => $this->faker->paragraph(),
2020-12-22 20:11:22 +00:00
'path' => '/tmp/' . uniqid() . '.mp3',
'genre' => $this->faker->randomElement(['Rock', 'Pop', 'Jazz', 'Classical', 'Metal', 'Hip Hop', 'Rap']),
'year' => $this->faker->year(),
'mtime' => time(),
];
}
}