feat/factory_creation (#1)
Prepping for launch. Reviewed-on: #1 Co-authored-by: Paul Couture <paul@paulcouture.com> Co-committed-by: Paul Couture <paul@paulcouture.com>
This commit was merged in pull request #1.
This commit is contained in:
@@ -2,10 +2,20 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Artist;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Str;
|
||||
|
||||
class ArtistFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Artist::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
@@ -13,8 +23,17 @@ class ArtistFactory extends Factory
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$name = fake()->name();
|
||||
$slug = Str::slug(strtolower(trim($name)));
|
||||
return [
|
||||
//
|
||||
'user_id' => User::factory(),
|
||||
'name' => $name,
|
||||
'slug' => $slug,
|
||||
'avatar' => fake()->imageUrl(512, 512),
|
||||
'header' => fake()->imageUrl(270, 185),
|
||||
'location' => fake()->city() . ', ' . fake()->state(),
|
||||
'website' => rand(0, 1) ? fake()->url : null,
|
||||
'bio' => fake()->paragraphs(rand(1, 3), true),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,23 @@
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Artist;
|
||||
use App\Models\Artwork;
|
||||
use App\Models\Episode;
|
||||
use App\Models\Podcast;
|
||||
use App\Models\Overlay;
|
||||
|
||||
class ArtworkFactory extends Factory
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of the factory's corresponding model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Artwork::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
@@ -13,8 +27,19 @@ class ArtworkFactory extends Factory
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$created = fake()->dateTimeThisDecade();
|
||||
return [
|
||||
//
|
||||
'title' => fake()->name(),
|
||||
'description' => rand(0, 1) ? fake()->paragraphs(rand(1, 3), true) : null,
|
||||
'artist_id' => Artist::factory(),
|
||||
'podcast_id' => Podcast::factory(),
|
||||
'episode_id' => Episode::factory(),
|
||||
'overlay_id' => rand(0, 1) ? Overlay::factory() : null,
|
||||
'filename' => fake()->imageUrl(3000, 3000),
|
||||
'created_at' => $created,
|
||||
'updated_at' => $created,
|
||||
'legacy_id' => null,
|
||||
'approved_by' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,24 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Artist;
|
||||
use App\Models\Artwork;
|
||||
use App\Models\Episode;
|
||||
use App\Models\Podcast;
|
||||
use App\Models\Overlay;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EpisodeFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Episode::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
@@ -13,8 +27,20 @@ class EpisodeFactory extends Factory
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$title = fake()->name();
|
||||
$slug = Str::slug($title);
|
||||
$created = fake()->dateTimeThisDecade();
|
||||
return [
|
||||
//
|
||||
'podcast_id' => Podcast::factory(),
|
||||
'artwork_id' => Artwork::factory(),
|
||||
'published' => fake()->boolean(),
|
||||
'episode_date' => fake()->dateTimeThisDecade(),
|
||||
'slug' => $slug,
|
||||
'title' => $title,
|
||||
'mp3' => fake()->url(),
|
||||
'created_at' => $created,
|
||||
'updated_at' => $created,
|
||||
'legacy_id' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,24 @@
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Artist;
|
||||
use App\Models\Artwork;
|
||||
use App\Models\Episode;
|
||||
use App\Models\Podcast;
|
||||
use App\Models\Overlay;
|
||||
|
||||
|
||||
class OverlayFactory extends Factory
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of the factory's corresponding model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Overlay::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
@@ -13,8 +28,14 @@ class OverlayFactory extends Factory
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$name = fake()->name();
|
||||
$slug = Str::slug($name);
|
||||
return [
|
||||
//
|
||||
'name' => $name,
|
||||
'artist_id' => Artist::factory(),
|
||||
'podcast_id' => Podcast::factory(),
|
||||
'available' => fake()->boolean(),
|
||||
'filename' => fake()->imageUrl(3000, 3000),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,21 @@ namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Artist;
|
||||
use App\Models\Artwork;
|
||||
use App\Models\Episode;
|
||||
use App\Models\Podcast;
|
||||
use App\Models\Overlay;
|
||||
|
||||
class PodcastFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Podcast::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
@@ -14,12 +26,14 @@ class PodcastFactory extends Factory
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$name = fake()->name();
|
||||
$slug = Str::slug($name);
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'name' => $name,
|
||||
'description' => fake()->paragraphs(rand(1,3), true),
|
||||
'website' => 'https://' . fake()->domainName(),
|
||||
'feed' => fake()->url(),
|
||||
'slug' => fake()->slug(),
|
||||
'feed' => 'podcast/' . $slug,
|
||||
'slug' => $slug,
|
||||
'published' => fake()->boolean(),
|
||||
'added_at' => fake()->dateTimeThisDecade(),
|
||||
];
|
||||
|
||||
@@ -4,9 +4,23 @@ namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Models\Artist;
|
||||
use App\Models\Artwork;
|
||||
use App\Models\Episode;
|
||||
use App\Models\Podcast;
|
||||
use App\Models\Overlay;
|
||||
use App\Models\User;
|
||||
|
||||
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = User::class;
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
@@ -14,12 +28,14 @@ class UserFactory extends Factory
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$password = Hash::make(Str::random(rand(8, 16)));
|
||||
return [
|
||||
'name' => $this->faker->name(),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||
'password' => $password,
|
||||
'remember_token' => Str::random(10),
|
||||
'legacy_id' => null,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user