From 021eae9bf4c4ea113664e113ab8d6f0835bcd378 Mon Sep 17 00:00:00 2001 From: Rico van Zelst Date: Fri, 27 Oct 2023 10:20:17 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=88=20Skin=20Chromas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/SkinChromaController.php | 66 +++++++++++++++++++ app/Http/Requests/StoreSkinChromaRequest.php | 28 ++++++++ app/Http/Requests/UpdateSkinChromaRequest.php | 28 ++++++++ app/Models/ChampionSkin.php | 11 +++- app/Models/SkinChroma.php | 24 +++++++ app/Policies/SkinChromaPolicy.php | 66 +++++++++++++++++++ database/factories/SkinChromaFactory.php | 23 +++++++ database/factories/UserFactory.php | 6 +- ..._26_175822_create_champion_skins_table.php | 2 +- ...10_27_080159_create_skin_chromas_table.php | 35 ++++++++++ database/seeders/SkinChromaSeeder.php | 17 +++++ 11 files changed, 297 insertions(+), 9 deletions(-) create mode 100644 app/Http/Controllers/SkinChromaController.php create mode 100644 app/Http/Requests/StoreSkinChromaRequest.php create mode 100644 app/Http/Requests/UpdateSkinChromaRequest.php create mode 100644 app/Models/SkinChroma.php create mode 100644 app/Policies/SkinChromaPolicy.php create mode 100644 database/factories/SkinChromaFactory.php create mode 100644 database/migrations/2023_10_27_080159_create_skin_chromas_table.php create mode 100644 database/seeders/SkinChromaSeeder.php diff --git a/app/Http/Controllers/SkinChromaController.php b/app/Http/Controllers/SkinChromaController.php new file mode 100644 index 0000000..cdd0232 --- /dev/null +++ b/app/Http/Controllers/SkinChromaController.php @@ -0,0 +1,66 @@ +|string> + */ + public function rules(): array + { + return [ + // + ]; + } +} diff --git a/app/Http/Requests/UpdateSkinChromaRequest.php b/app/Http/Requests/UpdateSkinChromaRequest.php new file mode 100644 index 0000000..c656cc6 --- /dev/null +++ b/app/Http/Requests/UpdateSkinChromaRequest.php @@ -0,0 +1,28 @@ +|string> + */ + public function rules(): array + { + return [ + // + ]; + } +} diff --git a/app/Models/ChampionSkin.php b/app/Models/ChampionSkin.php index 4e7ff74..4940cf4 100644 --- a/app/Models/ChampionSkin.php +++ b/app/Models/ChampionSkin.php @@ -41,18 +41,23 @@ class ChampionSkin extends Model return $this->belongsTo(Champion::class); } + public function chromas() + { + return $this->hasMany(SkinChroma::class, 'full_skin_id', 'full_skin_id'); + } + public function getSkinImageAttribute() { - return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/splash-art/centered/skin/'.$this->skin_id; + return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/splash-art/centered/skin/' . $this->skin_id; } public function getSkinImageLoadingAttribute() { - return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/portrait/skin/'.$this->skin_id; + return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/portrait/skin/' . $this->skin_id; } public function getSkinImageTileAttribute() { - return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/tile/skin/'.$this->skin_id; + return 'https://cdn.communitydragon.org/latest/champion/' . $this->champion_id . '/tile/skin/' . $this->skin_id; } } diff --git a/app/Models/SkinChroma.php b/app/Models/SkinChroma.php new file mode 100644 index 0000000..95b7eaa --- /dev/null +++ b/app/Models/SkinChroma.php @@ -0,0 +1,24 @@ +belongsTo(Skin::class); + } +} diff --git a/app/Policies/SkinChromaPolicy.php b/app/Policies/SkinChromaPolicy.php new file mode 100644 index 0000000..adbcc8a --- /dev/null +++ b/app/Policies/SkinChromaPolicy.php @@ -0,0 +1,66 @@ + + */ +class SkinChromaFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index a6ecc0a..73a012e 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -18,11 +18,7 @@ class UserFactory extends Factory public function definition(): array { return [ - 'name' => fake()->name(), - 'email' => fake()->unique()->safeEmail(), - 'email_verified_at' => now(), - 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password - 'remember_token' => Str::random(10), + ]; } diff --git a/database/migrations/2023_10_26_175822_create_champion_skins_table.php b/database/migrations/2023_10_26_175822_create_champion_skins_table.php index 5cf59c1..19c221e 100644 --- a/database/migrations/2023_10_26_175822_create_champion_skins_table.php +++ b/database/migrations/2023_10_26_175822_create_champion_skins_table.php @@ -15,7 +15,7 @@ return new class extends Migration $table->id(); $table->integer('champion_id'); - $table->integer('full_skin_id'); + $table->unsignedBigInteger('full_skin_id')->unique(); $table->integer('skin_id'); $table->string('skin_name'); $table->longText('lore'); diff --git a/database/migrations/2023_10_27_080159_create_skin_chromas_table.php b/database/migrations/2023_10_27_080159_create_skin_chromas_table.php new file mode 100644 index 0000000..104aa5c --- /dev/null +++ b/database/migrations/2023_10_27_080159_create_skin_chromas_table.php @@ -0,0 +1,35 @@ +id(); + + $table->unsignedBigInteger('full_skin_id'); + $table->string('skin_name'); + $table->string('chroma_name'); + $table->json('chroma_colors'); + $table->string('chroma_image'); + + $table->foreign('full_skin_id')->references('full_skin_id')->on('champion_skins'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('skin_chromas'); + } +}; diff --git a/database/seeders/SkinChromaSeeder.php b/database/seeders/SkinChromaSeeder.php new file mode 100644 index 0000000..5e9112c --- /dev/null +++ b/database/seeders/SkinChromaSeeder.php @@ -0,0 +1,17 @@ +