From b758fc9bb0e052b089f179bf2358a94d29a09852 Mon Sep 17 00:00:00 2001 From: Karl Murray Date: Thu, 28 Dec 2023 07:47:39 -0600 Subject: [PATCH] Code cleanup --- app/Http/Controllers/DashboardController.php | 2 +- app/Http/Controllers/DriverController.php | 8 +++- app/Http/Controllers/EventController.php | 18 ++++---- .../Controllers/FantasyTeamController.php | 7 ++- app/Http/Controllers/FaqController.php | 2 +- app/Http/Controllers/LeagueController.php | 8 ++-- app/Models/Constructor.php | 6 --- app/Models/FantasyTeam.php | 8 +--- app/Nova/Resource.php | 4 -- app/Nova/User.php | 5 -- app/Providers/NovaServiceProvider.php | 46 +++++++++---------- 11 files changed, 52 insertions(+), 62 deletions(-) diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 8cf960a..0facafd 100755 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -21,7 +21,7 @@ public function index(): Response 'franchises.name as franchise_name', 'franchises.slug as franchise_slug' ) - ->get() + ->get(), ]); } } diff --git a/app/Http/Controllers/DriverController.php b/app/Http/Controllers/DriverController.php index d6e36a7..6642eb3 100644 --- a/app/Http/Controllers/DriverController.php +++ b/app/Http/Controllers/DriverController.php @@ -58,7 +58,11 @@ public function show(Franchise $franchise, Driver $driver): Response ) ->get(); - return Inertia::render('Drivers/Show') - ->with(compact('driver', 'points', 'franchise', 'results')); + return Inertia::render('Drivers/Show', [ + 'driver' => $driver, + 'franchise' => $franchise, + 'points' => $points, + 'results' => $results, + ]); } } diff --git a/app/Http/Controllers/EventController.php b/app/Http/Controllers/EventController.php index e6aa827..dc219de 100644 --- a/app/Http/Controllers/EventController.php +++ b/app/Http/Controllers/EventController.php @@ -6,7 +6,6 @@ use App\Models\Franchise; use App\Models\Race; use App\Models\Result; -use App\Models\Track; use Inertia\Inertia; use Inertia\Response; @@ -20,8 +19,10 @@ public function index(Franchise $franchise): Response ->orderBy('date', 'ASC') ->get(); - return Inertia::render('Events/Index') - ->with(compact('franchise', 'events')); + return Inertia::render('Events/Index', [ + 'franchise' => $franchise, + 'events' => $events, + ]); } public function show(Franchise $franchise, Event $event): Response @@ -35,11 +36,10 @@ public function show(Franchise $franchise, Event $event): Response ->orderBy('starting_pos', 'ASC') ->get(); - return Inertia::render('Events/Show') - ->with(compact( - 'franchise', - 'event', - 'results' - )); + return Inertia::render('Events/Show', [ + 'franchise' => $franchise, + 'event' => $event, + 'results' => $results, + ]); } } diff --git a/app/Http/Controllers/FantasyTeamController.php b/app/Http/Controllers/FantasyTeamController.php index a46960e..3bc25fd 100644 --- a/app/Http/Controllers/FantasyTeamController.php +++ b/app/Http/Controllers/FantasyTeamController.php @@ -29,7 +29,10 @@ public function show(League $league, FantasyTeam $team): Response ->orderBy('results_sum_points_for_race', 'DESC') ->get(); - return Inertia::render('FantasyTeams/Show') - ->with(compact('league', 'team', 'drivers')); + return Inertia::render('FantasyTeams/Show', [ + 'league' => $league, + 'team' => $team, + 'drivers' => $drivers, + ]); } } diff --git a/app/Http/Controllers/FaqController.php b/app/Http/Controllers/FaqController.php index c20e69c..9f0700b 100644 --- a/app/Http/Controllers/FaqController.php +++ b/app/Http/Controllers/FaqController.php @@ -12,7 +12,7 @@ public function index(): Response { return Inertia::render('Faq', [ 'faqs' => DB::table('faq') - ->get() + ->get(), ]); } } diff --git a/app/Http/Controllers/LeagueController.php b/app/Http/Controllers/LeagueController.php index 808d69a..621a1e5 100755 --- a/app/Http/Controllers/LeagueController.php +++ b/app/Http/Controllers/LeagueController.php @@ -16,7 +16,7 @@ class LeagueController extends Controller public function create(): Response { return Inertia::render('Leagues/Create', [ - 'franchises' => Franchise::all() + 'franchises' => Franchise::all(), ]); } @@ -47,7 +47,9 @@ public function show(League $league): Response ->with(['drivers', 'user']) ->get(); - return Inertia::render('Leagues/Show') - ->with(compact('league', 'fantasyTeams')); + return Inertia::render('Leagues/Show', [ + 'league' => $league, + 'fantasyTeams' => $fantasyTeams, + ]); } } diff --git a/app/Models/Constructor.php b/app/Models/Constructor.php index 218a9fd..957b3a1 100755 --- a/app/Models/Constructor.php +++ b/app/Models/Constructor.php @@ -2,18 +2,12 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Builder; 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\HasManyThrough; -/** - * @mixin Builder - * - * @property int $id - */ class Constructor extends Model { use HasFactory; diff --git a/app/Models/FantasyTeam.php b/app/Models/FantasyTeam.php index 4fbb161..379d36b 100755 --- a/app/Models/FantasyTeam.php +++ b/app/Models/FantasyTeam.php @@ -2,27 +2,23 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasManyThrough; -/* @mixin Builder - * @property int $id - */ class FantasyTeam extends Model { use HasFactory; protected $guarded = ['id']; - public function User(): BelongsTo + public function user(): BelongsTo { return $this->belongsTo(User::class, 'user_id'); } - public function League(): BelongsTo + public function league(): BelongsTo { return $this->belongsTo(League::class, 'league_id') ->with('Franchise'); diff --git a/app/Nova/Resource.php b/app/Nova/Resource.php index 03277df..206170f 100644 --- a/app/Nova/Resource.php +++ b/app/Nova/Resource.php @@ -10,7 +10,6 @@ abstract class Resource extends NovaResource /** * Build an "index" query for the given resource. * - * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Database\Eloquent\Builder */ @@ -22,7 +21,6 @@ public static function indexQuery(NovaRequest $request, $query) /** * Build a Scout search query for the given resource. * - * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @param \Laravel\Scout\Builder $query * @return \Laravel\Scout\Builder */ @@ -34,7 +32,6 @@ public static function scoutQuery(NovaRequest $request, $query) /** * Build a "detail" query for the given resource. * - * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Database\Eloquent\Builder */ @@ -48,7 +45,6 @@ public static function detailQuery(NovaRequest $request, $query) * * This query determines which instances of the model may be attached to other resources. * - * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Database\Eloquent\Builder */ diff --git a/app/Nova/User.php b/app/Nova/User.php index a4b8c55..e1d45ae 100644 --- a/app/Nova/User.php +++ b/app/Nova/User.php @@ -38,7 +38,6 @@ class User extends Resource /** * Get the fields displayed by the resource. * - * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @return array */ public function fields(NovaRequest $request) @@ -68,7 +67,6 @@ public function fields(NovaRequest $request) /** * Get the cards available for the request. * - * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @return array */ public function cards(NovaRequest $request) @@ -79,7 +77,6 @@ public function cards(NovaRequest $request) /** * Get the filters available for the resource. * - * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @return array */ public function filters(NovaRequest $request) @@ -90,7 +87,6 @@ public function filters(NovaRequest $request) /** * Get the lenses available for the resource. * - * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @return array */ public function lenses(NovaRequest $request) @@ -101,7 +97,6 @@ public function lenses(NovaRequest $request) /** * Get the actions available for the resource. * - * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @return array */ public function actions(NovaRequest $request) diff --git a/app/Providers/NovaServiceProvider.php b/app/Providers/NovaServiceProvider.php index 429c6c2..ad9f47f 100644 --- a/app/Providers/NovaServiceProvider.php +++ b/app/Providers/NovaServiceProvider.php @@ -18,6 +18,26 @@ public function boot() parent::boot(); } + /** + * Get the tools that should be listed in the Nova sidebar. + * + * @return array + */ + public function tools() + { + return []; + } + + /** + * Register any application services. + * + * @return void + */ + public function register() + { + // + } + /** * Register the Nova routes. * @@ -26,9 +46,9 @@ public function boot() protected function routes() { Nova::routes() - ->withAuthenticationRoutes() - ->withPasswordResetRoutes() - ->register(); + ->withAuthenticationRoutes() + ->withPasswordResetRoutes() + ->register(); } /** @@ -58,24 +78,4 @@ protected function dashboards() new \App\Nova\Dashboards\Main, ]; } - - /** - * Get the tools that should be listed in the Nova sidebar. - * - * @return array - */ - public function tools() - { - return []; - } - - /** - * Register any application services. - * - * @return void - */ - public function register() - { - // - } }