Skip to content

Commit

Permalink
Start Transition to Nova
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmrr committed Dec 27, 2023
1 parent ff598cd commit ca4db91
Show file tree
Hide file tree
Showing 145 changed files with 4,879 additions and 6,101 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ yarn-error.log
/.idea
/.vscode
.DS_Store
.idea
_ide_helper.php.idea
Empty file added _ide_helper.php
Empty file.
16 changes: 0 additions & 16 deletions app/Http/Controllers/Auth/RegisteredUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,11 @@

class RegisteredUserController extends Controller
{
public function index(): Response
{
$users = User::all();

return Inertia::render('Admin/Users/Index')
->with(compact('users'));
}

/**
* Display the registration view.
*/
public function create(): Response
{
return Inertia::render('Auth/Register');
}

/**
* Handle an incoming registration request.
*
* @throws \Illuminate\Validation\ValidationException
*/
public function store(Request $request): RedirectResponse
{
$request->validate([
Expand Down
72 changes: 10 additions & 62 deletions app/Http/Controllers/ConstructorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

namespace App\Http\Controllers;

use App\Http\Requests\ConstructorRequest;
use App\Models\Constructor;
use App\Models\Driver;
use App\Models\Franchise;
use App\Models\Result;
use Illuminate\Support\Facades\DB;
use Inertia\Inertia;
use Inertia\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;

class ConstructorController extends Controller
{
Expand All @@ -24,25 +22,10 @@ public function index(Franchise $franchise): Response
->orderBy('results_sum_points_for_race', 'DESC')
->get();

return Inertia::render('Constructors/Index')
->with(compact('franchise', 'teams'));
}

public function create(): Response
{
$franchises = Franchise::all();

return Inertia::render('Admin/Constructors/Create')
->with(compact('franchises'));
}

public function store(ConstructorRequest $request): RedirectResponse
{
Constructor::create(
$request->validated()
);

return redirect()->route('admin.constructor.index');
return Inertia::render('Constructors/Index', [
'franchise' => $franchise,
'teams' => $teams,
]);
}

public function show(Franchise $franchise, string $slug): Response
Expand Down Expand Up @@ -74,46 +57,11 @@ public function show(Franchise $franchise, string $slug): Response
->orderBy('id', 'ASC')
->get();

return Inertia::render('Constructors/Show')
->with(compact(
'team',
'drivers',
'franchise',
'results'
));
}

public function edit(Constructor $team): Response
{
$team->load('franchise');

$franchises = Franchise::all();

return Inertia::render('Admin/Constructors/Edit')
->with(compact('franchises', 'team'));
}

public function update(Constructor $team, ConstructorRequest $request): RedirectResponse
{
$team->update(
$request->validated()
);

return redirect()->route('admin.constructor.index');
}

public function destroy(Constructor $team)
{
$team->delete();

return redirect()->route('admin.constructor.index');
}

public function adminIndex(): Response
{
$franchises = Franchise::all();

return Inertia::render('Admin/Constructors/Index')
->with(compact('franchises'));
return Inertia::render('Constructors/Show', [
'franchise' => $franchise,
'team' => $team,
'drivers' => $drivers,
'results' => $results,
]);
}
}
61 changes: 13 additions & 48 deletions app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,26 @@

namespace App\Http\Controllers;

use App\Models\Constructor;
use App\Models\Driver;
use App\Models\Event;
use App\Models\FantasyTeam;
use App\Models\Franchise;
use App\Models\League;
use App\Models\Result;
use App\Models\Track;
use App\Models\User;
use Inertia\Inertia;
use Inertia\Response;

class DashboardController extends Controller
{
public function index(): Response
{
$fantasy_teams = FantasyTeam::query()
->where('user_id', auth()->id())
->join('leagues', 'leagues.id', 'fantasy_teams.league_id')
->join('franchises', 'franchises.id', 'leagues.franchise_id')
->select(
'fantasy_teams.*',
'leagues.name as league_name',
'franchises.name as franchise_name',
'franchises.slug as franchise_slug'
)
->get();

return Inertia::render('Dashboard')
->with(compact('fantasy_teams'));
}

public function adminIndex(): Response
{
$users = User::all()->count();
$franchises = Franchise::all()->count();
$drivers = Driver::all()->count();
$events = Event::all()->count();
$results = Result::all()->count();
$fantasyTeams = FantasyTeam::all()->count();
$tracks = Track::all()->count();
$leagues = League::all()->count();
$constructors = Constructor::all()->count();

return Inertia::render('Admin/Dashboard')
->with(compact(
'users',
'franchises',
'constructors',
'drivers',
'events',
'results',
'fantasyTeams',
'tracks',
'leagues'
));
return Inertia::render('Dashboard', [
'fantasy_teams' => FantasyTeam::query()
->where('user_id', auth()->id())
->join('leagues', 'leagues.id', 'fantasy_teams.league_id')
->join('franchises', 'franchises.id', 'leagues.franchise_id')
->select(
'fantasy_teams.*',
'leagues.name as league_name',
'franchises.name as franchise_name',
'franchises.slug as franchise_slug'
)
->get()
]);
}
}
58 changes: 5 additions & 53 deletions app/Http/Controllers/DriverController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace App\Http\Controllers;

use App\Http\Requests\DriverRequest;
use App\Models\Constructor;
use App\Models\Driver;
use App\Models\Franchise;
use App\Models\Result;
use Illuminate\Http\RedirectResponse;
use Inertia\Inertia;
use Inertia\Response;

Expand All @@ -31,25 +29,11 @@ public function index(Franchise $franchise): Response
->orderBy('results_sum_points_for_race', 'DESC')
->get();

return Inertia::render('Drivers/Index')
->with(compact('drivers', 'franchise', 'constructors'));
}

public function create(): Response
{
$franchises = Franchise::all();

return Inertia::render('Admin/Drivers/Create')
->with(compact('franchises'));
}

public function store(DriverRequest $request): RedirectResponse
{
Driver::create(
$request->validated()
);

return Redirect(route('admin.driver.index'));
return Inertia::render('Drivers/Index', [
'drivers' => $drivers,
'franchise' => $franchise,
'constructors' => $constructors,
]);
}

public function show(Franchise $franchise, Driver $driver): Response
Expand Down Expand Up @@ -77,36 +61,4 @@ public function show(Franchise $franchise, Driver $driver): Response
return Inertia::render('Drivers/Show')
->with(compact('driver', 'points', 'franchise', 'results'));
}

public function edit(Driver $driver)
{
$franchises = Franchise::all();

$driver->load('constructor', 'constructor.franchise');

return Inertia::render('Admin/Drivers/Edit')
->with(compact('franchises', 'driver'));
}

public function update(Driver $driver, DriverRequest $request)
{
$driver->update($request->validated());

return Redirect(route('admin.driver.index'));
}

public function destroy(Driver $driver)
{
$driver->delete();

return Redirect(route('admin.driver.index'));
}

public function adminIndex(): Response
{
$franchises = Franchise::all();

return Inertia::render('Admin/Drivers/Index')
->with(compact('franchises'));
}
}
57 changes: 0 additions & 57 deletions app/Http/Controllers/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

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;

Expand All @@ -26,24 +24,6 @@ public function index(Franchise $franchise): Response
->with(compact('franchise', 'events'));
}

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

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

public function store(Franchise $franchise, EventRequest $request): RedirectResponse
{
Event::create(
$request->validated()
);

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

public function show(Franchise $franchise, Event $event): Response
{
$event->load('track');
Expand All @@ -62,41 +42,4 @@ public function show(Franchise $franchise, Event $event): Response
'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'));
}

public function adminIndex()
{
$franchises = Franchise::all();

return Inertia::render(
'Admin/Events/Index',
['franchises' => $franchises]
);
}
}
9 changes: 4 additions & 5 deletions app/Http/Controllers/FaqController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ class FaqController extends Controller
{
public function index(): Response
{
$faqs = DB::table('faq')
->get();

return Inertia::render('Faq')
->with(compact('faqs'));
return Inertia::render('Faq', [
'faqs' => DB::table('faq')
->get()
]);
}
}
Loading

0 comments on commit ca4db91

Please sign in to comment.