feat: factory creation and initial theme work

This commit is contained in:
2023-07-29 01:05:43 -05:00
parent 1833524f7f
commit 5c218918ee
213 changed files with 46351 additions and 1923 deletions

View File

@@ -2,10 +2,19 @@
namespace Database\Factories;
use App\Models\Artist;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class ArtistFactory extends Factory
{
/**
* The name of the factory's corresponding model
*
* @var string
*/
protected $model = Artist::class;
/**
* Define the model's default state.
*
@@ -14,7 +23,13 @@ class ArtistFactory extends Factory
public function definition()
{
return [
//
'user_id' => User::factory(),
'name' => fake()->name(),
'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)),
];
}
}

View File

@@ -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.
*
@@ -14,7 +28,13 @@ class ArtworkFactory extends Factory
public function definition()
{
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),
];
}
}

View File

@@ -2,10 +2,21 @@
namespace Database\Factories;
use App\Models\Episode;
use App\Models\Podcast;
use App\Models\Artwork;
use Illuminate\Database\Eloquent\Factories\Factory;
class EpisodeFactory extends Factory
{
/**
* The name of the factory's corresponding model
*
* @var string
*/
protected $model = Episode::class;
/**
* Define the model's default state.
*
@@ -14,7 +25,10 @@ class EpisodeFactory extends Factory
public function definition()
{
return [
//
'podcast_id' => Podcast::factory(),
'artwork_id' => Artwork::factory(),
'published' => fake()->boolean(),
'title' => fake()->name()
];
}
}

View File

@@ -3,6 +3,10 @@
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use App\Models\Podcast;
use App\Models\Artist;
class OverlayFactory extends Factory
{
@@ -13,8 +17,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),
];
}
}

View File

@@ -4,6 +4,7 @@ namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use App\Models\Podcast;
class PodcastFactory extends Factory
{
@@ -14,12 +15,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(),
];

View File

@@ -4,6 +4,7 @@ namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Hash;
class UserFactory extends Factory
{
@@ -14,11 +15,12 @@ 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),
];
}

View File

@@ -15,7 +15,10 @@ class CreateArtistsTable extends Migration
{
Schema::create('artists', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained();
$table->foreignIdFor(User::class)
->constrained()
->cascadeOnUpdate()
->cascadeOnDelete();
$table->string('name')->unique();
$table->string('avatar')->nullable();
$table->string('header')->nullable();