F
Filament6mo ago
vas

Attempted to lazy load [payment] on model [App\Models\Order] but lazy loading is disabled.

i have the following action in the OrderResource
Tables\Actions\Action::make('Download Factura')
->icon('heroicon-o-credit-card')
->color('indigo')
->hidden(fn (Order $order) => $order->payment->status != PaymentStatusEnum::PAID->value)
->url(fn (Order $order) => route('stripe.retrieve.invoice', $order->payment))
->openUrlInNewTab(),
Tables\Actions\Action::make('Download Factura')
->icon('heroicon-o-credit-card')
->color('indigo')
->hidden(fn (Order $order) => $order->payment->status != PaymentStatusEnum::PAID->value)
->url(fn (Order $order) => route('stripe.retrieve.invoice', $order->payment))
->openUrlInNewTab(),
Route::get('/stripe/retrieve_invoice/{payment}', 'App\Http\Controllers\StripeController@retrieve_invoice')->name('stripe.retrieve.invoice');
Route::get('/stripe/retrieve_invoice/{payment}', 'App\Http\Controllers\StripeController@retrieve_invoice')->name('stripe.retrieve.invoice');
as you can see im trying to pass the payment to that route normally i would have
Order::with('payment')
Order::with('payment')
how can i achieve this in filament Thank you
2 Replies
Dennis Koch
Dennis Koch6mo ago
It's not really a Filament issue. You disabled lazy loading the relationships and then are accessing a relationship that isn't loaded yet. You can use $order->load('payment') in that case
vas
vas6mo ago
Yes you are correct I’ve disabled it to avoid n+1 queries Thanks