koel/database/factories/ModelFactory.php

50 lines
1.3 KiB
PHP
Raw Normal View History

2015-12-13 04:42:28 +00:00
<?php
$factory->define(App\Models\User::class, function ($faker) {
return [
'name' => $faker->name,
'email' => $faker->email,
'password' => bcrypt(str_random(10)),
'is_admin' => false,
2015-12-20 12:17:35 +00:00
'preferences' => [],
2015-12-13 04:42:28 +00:00
'remember_token' => str_random(10),
];
});
$factory->defineAs(App\Models\User::class, 'admin', function ($faker) use ($factory) {
$user = $factory->raw(App\Models\User::class);
return array_merge($user, ['is_admin' => true]);
});
$factory->define(App\Models\Artist::class, function ($faker) {
return [
'name' => $faker->name,
2015-12-22 09:53:03 +00:00
'image' => md5(uniqid()).'.jpg',
2015-12-13 04:42:28 +00:00
];
});
$factory->define(App\Models\Album::class, function ($faker) {
return [
'name' => $faker->sentence,
'cover' => md5(uniqid()).'.jpg',
];
});
$factory->define(App\Models\Song::class, function ($faker) {
return [
'title' => $faker->sentence,
'length' => $faker->randomFloat(2, 10, 500),
'track' => $faker->randomNumber(),
2015-12-13 04:42:28 +00:00
'lyrics' => $faker->paragraph(),
'path' => '/tmp/'.uniqid().'.mp3',
'mtime' => time(),
];
});
$factory->define(App\Models\Playlist::class, function ($faker) {
return [
'name' => $faker->name,
];
});