Skip to content

Commit

Permalink
Use Laravel native route model binding for merch distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
kberzinch committed Jul 28, 2024
1 parent e7dfad2 commit 394c736
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 0 additions & 3 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Laravel\Horizon\Horizon;
use Laravel\Horizon\MasterSupervisor;
Expand Down Expand Up @@ -142,7 +141,5 @@ public function bootRoute(): void
'api',
static fn (Request $request): Limit => Limit::perMinute(60)->by($request->user()?->id ?: $request->ip())
);

Route::bind('gtid', static fn (string $value): User => User::whereGtid($value)->firstOrFail());
}
}
7 changes: 5 additions & 2 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ static function (): void {

// Merchandise
Route::get('merchandise', [MerchandiseController::class, 'index']);
Route::get('merchandise/{merchandise}/distribute/{gtid}', [MerchandiseController::class, 'getDistribution']);
Route::post('merchandise/{merchandise}/distribute/{gtid}', [MerchandiseController::class, 'distribute']);
Route::get(
'merchandise/{merchandise}/distribute/{user:gtid}',
[MerchandiseController::class, 'getDistribution']
);
Route::post('merchandise/{merchandise}/distribute/{user:gtid}', [MerchandiseController::class, 'distribute']);
}
);

Expand Down

0 comments on commit 394c736

Please sign in to comment.