Skip to content

Commit

Permalink
feat: default item types
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrinsieboy authored Jan 11, 2024
2 parents 5cba4f9 + 3474226 commit 0adaffb
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/app/Enums/ItemTypes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Enums;

enum ItemTypes: string
{
case book = 'book';
case movie = 'movie';
case game = 'game';
case music = 'music';
case ebook = 'ebook';
case audiobook = 'audiobook';
case magazine = 'magazine';

public function label(): string
{
return match ($this) {
static::book => 'Book',
static::movie => 'Movie',
static::game => 'Game',
static::music => 'Music',
static::ebook => 'Ebook',
static::audiobook => 'Audiobook',
static::magazine => 'Magazine',
};
}

public function internal(): string
{
$match = match ($this) {
static::book => 'book',
static::movie => 'movie',
static::game => 'game',
static::music => 'music',
static::ebook => 'ebook',
static::audiobook => 'audiobook',
static::magazine => 'magazine',
};

return strtoupper($match);
}
}
72 changes: 72 additions & 0 deletions src/database/seeders/ItemSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace Database\Seeders;

use App\Models\ItemAgeRating;
use App\Models\ItemCategory;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class ItemSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$ratings = [
"All ages",
"1-3",
"4-8",
"8-12",
"12-14",
"14-16",
"16-18",
"18+",
];

// RATINGS
foreach ($ratings as $rating) {
ItemAgeRating::create([
'rating' => $rating,
'modified_user' => User::where('email', '[email protected]')->first()->id,
'modified_kind' => 'I',
]);
}

// CATEGORIES
$categories = [
"Action",
"Adventure",
"Animation",
"Biography",
"Comedy",
"Crime",
"Documentary",
"Drama",
"Family",
"Fantasy",
"Film-Noir",
"History",
"Horror",
"Music",
"Musical",
"Mystery",
"Romance",
"Sci-Fi",
"Sport",
"Thriller",
"War",
"Western",
];

foreach ($categories as $category) {
ItemCategory::create([
'category' => $category,
'modified_user' => User::where('email', '[email protected]')->first()->id,
'modified_kind' => 'I'
]);
}
}
}

0 comments on commit 0adaffb

Please sign in to comment.