Auditions admin index complete
This commit is contained in:
parent
ddb5b7a71e
commit
91f47717d3
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Audition;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AuditionController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
if(! Auth::user()->is_admin) abort(403);
|
||||
$auditions = Audition::with(['event','entries'])->orderBy('score_order')->paginate(10);
|
||||
return view('admin.auditions.index', ['auditions' => $auditions] );
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
if(! Auth::user()->is_admin) abort(403);
|
||||
return view('admin.auditions.create');
|
||||
}
|
||||
|
||||
public function edit(Audition $audition)
|
||||
{
|
||||
if(! Auth::user()->is_admin) abort(403);
|
||||
return view('admin.auditions.edit', ['audition' => $audition]);
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ class EntryController extends Controller
|
|||
public function index()
|
||||
{
|
||||
if(! Auth::user()->is_admin) abort(403);
|
||||
$entries = Entry::with(['student.school','audition'])->orderBy('created_at','DESC')->paginate(10);
|
||||
$entries = Entry::with(['student.school','audition'])->orderBy('updated_at','DESC')->paginate(10);
|
||||
return view('admin.entries.index', ['entries' => $entries] );
|
||||
}
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ class EntryController extends Controller
|
|||
{
|
||||
if(! Auth::user()->is_admin) abort(403);
|
||||
$students = Student::with('school')->orderBy('last_name')->orderBy('first_name')->get();
|
||||
$auditions = Audition::orderBy('name')->get();
|
||||
$auditions = Audition::orderBy('score_order')->get();
|
||||
return view('admin.entries.create', ['students' => $students, 'auditions' => $auditions]);
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ class EntryController extends Controller
|
|||
{
|
||||
if(! Auth::user()->is_admin) abort(403);
|
||||
$students = Student::with('school')->orderBy('last_name')->orderBy('first_name')->get();
|
||||
$auditions = Audition::orderBy('name')->get();
|
||||
$auditions = Audition::orderBy('score_order')->get();
|
||||
return view('admin.entries.edit', ['entry' => $entry, 'students' => $students, 'auditions' => $auditions]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,21 +5,39 @@ namespace App\Models;
|
|||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use function now;
|
||||
|
||||
class Audition extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function event(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Event::class);
|
||||
}
|
||||
protected $guarded = [];
|
||||
|
||||
public static function deadlineNotPast()
|
||||
{
|
||||
return Audition::where('entry_deadline', '>=', now())->get();
|
||||
}
|
||||
|
||||
public function event(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Event::class);
|
||||
}
|
||||
|
||||
public function entries(): HasMany
|
||||
{
|
||||
return $this->hasMany(Entry::class);
|
||||
}
|
||||
|
||||
public function dislpay_fee(): String
|
||||
{
|
||||
return '$' . number_format($this->entry_fee / 100, 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO add order column to be able to sort in score order
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('auditions', function (Blueprint $table) {
|
||||
//Rename the score column score_order
|
||||
$table->renameColumn('order', 'score_order');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('auditions', function (Blueprint $table) {
|
||||
$table->renameColumn('score_order', 'order');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -54,7 +54,7 @@ class AuditionSeeder extends Seeder
|
|||
DB::table('auditions')->insert([
|
||||
'event_id' => $event->id,
|
||||
'name' => $level . ' ' . $instrument,
|
||||
'order' => $n,
|
||||
'score_order' => $n,
|
||||
'entry_deadline' => '2040-12-31',
|
||||
'entry_fee' => '1000',
|
||||
'minimum_grade' => $minGrade,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
<x-layout.app>
|
||||
<x-slot:page_title>Audition Administration</x-slot:page_title>
|
||||
|
||||
<x-card.card>
|
||||
<x-table.table with_title_area>
|
||||
<x-slot:title class="ml-3">Auditions</x-slot:title>
|
||||
<x-slot:subtitle class="ml-3">Click name to edit</x-slot:subtitle>
|
||||
<x-slot:title_block_right class="mr-3">
|
||||
<x-form.button href="/admin/entries/create">New Audition</x-form.button>
|
||||
</x-slot:title_block_right>
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<x-table.th>Event</x-table.th>
|
||||
<x-table.th>Name</x-table.th>
|
||||
<x-table.th>Order</x-table.th>
|
||||
<x-table.th>Deadline</x-table.th>
|
||||
<x-table.th>Entry Fee</x-table.th>
|
||||
<x-table.th>Grade Range</x-table.th>
|
||||
<x-table.th>Entries</x-table.th>
|
||||
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<x-table.body>
|
||||
@foreach($auditions as $audition)
|
||||
<tr>
|
||||
<x-table.td>{{ $audition->event->name }}</x-table.td>
|
||||
<x-table.td>{{ $audition->name }}</x-table.td>
|
||||
<x-table.td>{{ $audition->score_order }}</x-table.td>
|
||||
<x-table.td>{{ $audition->entry_deadline }}</x-table.td>
|
||||
<x-table.td>{{ $audition->dislpay_fee() }}</x-table.td>
|
||||
<x-table.td>{{ $audition->minimum_grade }} - {{ $audition->maximum_grade }}</x-table.td>
|
||||
<x-table.td>{{ $audition->entries->count() }}</x-table.td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</x-table.body>
|
||||
</x-table.table>
|
||||
|
||||
</x-card.card>
|
||||
<div class="mt-3 mx-3">
|
||||
{{ $auditions->links('vendor.pagination.simple-audition') }}
|
||||
</div>
|
||||
</x-layout.app>
|
||||
{{--TODO add options to filter the page--}}
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
</x-form.select>
|
||||
</x-form.body-grid>
|
||||
<x-form.footer>
|
||||
<x-form.button>Create Entry</x-form.button>
|
||||
<x-form.button>Edit Entry</x-form.button>
|
||||
</x-form.footer>
|
||||
</x-form.form>
|
||||
</x-card.card>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
<x-layout.nav-link href="/admin/schools" :active="request()->is('admin/schools')">Schools</x-layout.nav-link>
|
||||
<x-layout.nav-link href="/admin/students" :active="request()->is('admin/students')">Students</x-layout.nav-link>
|
||||
<x-layout.nav-link href="/admin/entries" :active="request()->is('admin/entries')">Entries</x-layout.nav-link>
|
||||
<x-layout.nav-link href="/admin/auditions" :active="request()->is('admin/auditions')">Auditions</x-layout.nav-link>
|
||||
{{-- <a href="/dashboard" class="bg-indigo-700 text-white rounded-md px-3 py-2 text-sm font-medium" aria-current="page">Dashboard</a>--}}
|
||||
|
||||
{{-- <a href="/students" class="text-white hover:bg-indigo-500 hover:bg-opacity-75 rounded-md px-3 py-2 text-sm font-medium">Students</a>--}}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,15 @@ Route::view('/','welcome')->middleware('guest');
|
|||
Route::middleware(['auth','verified',CheckIfAdmin::class])->prefix('admin/')->group(function() {
|
||||
Route::view('/','admin.dashboard');
|
||||
|
||||
// Admin Auditions Routes
|
||||
Route::prefix('auditions')->controller(\App\Http\Controllers\Admin\AuditionController::class)->group(function() {
|
||||
Route::get('/','index');
|
||||
Route::get('/create','create');
|
||||
Route::post('/','store');
|
||||
Route::get('/{entry}/edit','edit');
|
||||
Route::patch('/{entry}','update');
|
||||
});
|
||||
|
||||
// Admin Entries Routes
|
||||
Route::prefix('entries')->controller(\App\Http\Controllers\Admin\EntryController::class)->group(function() {
|
||||
Route::get('/','index');
|
||||
|
|
|
|||
Loading…
Reference in New Issue