From a452234c44ed0e4ca2d5d2149cdd334dcd11a1cc Mon Sep 17 00:00:00 2001 From: Matt Young Date: Thu, 30 May 2024 22:22:25 -0500 Subject: [PATCH] Entry model setup --- app/Http/Controllers/EntryController.php | 10 +++ app/Models/Audition.php | 7 ++ app/Models/Entry.php | 22 +++++++ app/Models/Event.php | 6 ++ app/Policies/EntryPolicy.php | 66 +++++++++++++++++++ database/factories/EntryFactory.php | 23 +++++++ ...2024_05_31_031713_create_entries_table.php | 31 +++++++++ database/seeders/EntrySeeder.php | 17 +++++ .../views/components/layout/navbar.blade.php | 1 + routes/web.php | 3 + 10 files changed, 186 insertions(+) create mode 100644 app/Http/Controllers/EntryController.php create mode 100644 app/Models/Entry.php create mode 100644 app/Policies/EntryPolicy.php create mode 100644 database/factories/EntryFactory.php create mode 100644 database/migrations/2024_05_31_031713_create_entries_table.php create mode 100644 database/seeders/EntrySeeder.php diff --git a/app/Http/Controllers/EntryController.php b/app/Http/Controllers/EntryController.php new file mode 100644 index 0000000..8d536da --- /dev/null +++ b/app/Http/Controllers/EntryController.php @@ -0,0 +1,10 @@ +belongsTo(Event::class); + } } diff --git a/app/Models/Entry.php b/app/Models/Entry.php new file mode 100644 index 0000000..a152d60 --- /dev/null +++ b/app/Models/Entry.php @@ -0,0 +1,22 @@ +belongsTo(Student::class); + } + + public function audition(): BelongsTo + { + return $this->belongsTo(Audition::class); + } +} diff --git a/app/Models/Event.php b/app/Models/Event.php index cbd6b41..aaba68a 100644 --- a/app/Models/Event.php +++ b/app/Models/Event.php @@ -4,8 +4,14 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\HasMany; class Event extends Model { use HasFactory; + + public function auditions(): HasMany + { + return $this->hasMany(Audition::class); + } } diff --git a/app/Policies/EntryPolicy.php b/app/Policies/EntryPolicy.php new file mode 100644 index 0000000..4e4b6d8 --- /dev/null +++ b/app/Policies/EntryPolicy.php @@ -0,0 +1,66 @@ + + */ +class EntryFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/migrations/2024_05_31_031713_create_entries_table.php b/database/migrations/2024_05_31_031713_create_entries_table.php new file mode 100644 index 0000000..0155ed9 --- /dev/null +++ b/database/migrations/2024_05_31_031713_create_entries_table.php @@ -0,0 +1,31 @@ +id(); + $table->foreignIdFor(Student::class)->constrained()->restrictOnDelete()->cascadeOnUpdate(); + $table->foreignIdFor(Audition::class)->constrained()->restrictOnDelete()->cascadeOnUpdate(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('entries'); + } +}; diff --git a/database/seeders/EntrySeeder.php b/database/seeders/EntrySeeder.php new file mode 100644 index 0000000..ab64b8a --- /dev/null +++ b/database/seeders/EntrySeeder.php @@ -0,0 +1,17 @@ + Dashboard Students + Entries {{-- Dashboard--}} {{-- Students--}} diff --git a/routes/web.php b/routes/web.php index c741c98..601b5e8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -18,6 +18,9 @@ Route::middleware(['auth','verified'])->group(function () { Route::get('/my_school', [DashboardController::class, 'my_school']); }); +// Entry Related Routes + + // User Related Routes Route::middleware(['auth','verified'])->controller(UserController::class)->group(function() { Route::patch('/users/{user}/set_school', 'set_school');