F
Filamentβ€’13mo ago
ericmp

Using full component page & access url record in middleware

Lets say i have this route:
Route::get('payments/{payment}/pay', fn (Payment $payment) => \App\Livewire\PayPaymentComponent::class)
->name('payments.pay')
->middleware(PaymentNotPaid::class);
Route::get('payments/{payment}/pay', fn (Payment $payment) => \App\Livewire\PayPaymentComponent::class)
->name('payments.pay')
->middleware(PaymentNotPaid::class);
right now, if i visit it, i get this:
App\Livewire\PayPaymentComponent
App\Livewire\PayPaymentComponent
which is literally a blank html page with that text πŸ€¦β€β™‚οΈ if i change it to this:
Route::get('payments/{payment}/pay', \App\Livewire\PayPaymentComponent::class)
->name('payments.pay')
->middleware(PaymentNotPaid::class);
Route::get('payments/{payment}/pay', \App\Livewire\PayPaymentComponent::class)
->name('payments.pay')
->middleware(PaymentNotPaid::class);
now the middleware is not able to access the $request->payment model πŸ€¦β€β™‚οΈ how would u solve this?
No description
1 Reply
ericmp
ericmpOPβ€’13mo ago
i could solve it by doing $payment = Payment::findOrFail($request->payment); in the middleware, but idk, im adding an extra query to the route. not sure, but at the moment is what im doing temporarily

Did you find this page helpful?