Skip to content

Commit

Permalink
who knows.
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmrr committed Aug 19, 2023
1 parent f5a42f8 commit efe6a26
Show file tree
Hide file tree
Showing 8 changed files with 1,693 additions and 4,192 deletions.
67 changes: 55 additions & 12 deletions app/Http/Controllers/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

namespace App\Http\Controllers;

use App\Http\Requests\EventRequest;
use App\Models\Event;
use App\Models\Franchise;
use App\Models\Race;
use App\Models\Result;
use App\Models\Track;
use Illuminate\Http\RedirectResponse;
use Inertia\Inertia;
use Inertia\Response;

class EventController extends Controller
{
public function adminIndex()
{
$franchises = Franchise::get();
$franchises = Franchise::all();

return Inertia::render(
'Admin/Events/Index',
Expand All @@ -32,28 +35,68 @@ public function index(Franchise $franchise): Response
return Inertia::render('Events/Index')
->with(compact('franchise', 'events'));
}

public function create(): Response
public function create(Franchise $franchise): Response
{
$franchises = Franchise::get();
$tracks = Track::get();

$franchises = Franchise::all();
$tracks = Track::all();
return Inertia::render('Admin/Events/Create')
->with(compact('franchises', 'tracks'));
}

public function show(Franchise $franchise, Race $race): Response
public function store(Franchise $franchise, EventRequest $request): RedirectResponse
{
$event = $race->load('track');

Event::create(
$request->validated()
);

return redirect(route('admin.events.index'));
}

public function show(Franchise $franchise, Event $event): Response
{
$event->load('track');

$results = Result::query()
->where('race_id', $event->id)
->with('driver')
->orderBy('finish_pos', 'ASC')
->orderBy('starting_pos', 'ASC')
->get();

return Inertia::render('Events/Show')
->with(compact('franchise', 'event', 'results'));
->with(compact(
'franchise',
'event',
'results'
));
}

public function edit(Event $event): Response
{
$franchises = Franchise::get();
$tracks = Track::get();

return Inertia::render('Admin/Events/Edit')
->with(compact(
'franchises',
'tracks',
'event'
));
}

public function update(Event $event, EventRequest $request)
{
$event->update($request->validated());

return redirect(route('admin.events.index'));
}

public function destroy(Event $event)
{
$event->delete();

return redirect(route('admin.events.index'));
}
}
Loading

0 comments on commit efe6a26

Please sign in to comment.