-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
]); | ||
} | ||
} | ||
} |