url redirect not working

I am trying to create a redirect to a view page but this isn't working in laravel filament 3.
->actions([
Action::make('View Order')
->url(fn (Order $record): string => OrderResource::getUrl('view', $record))
->icon('heroicon-m-eye'),
]);
->actions([
Action::make('View Order')
->url(fn (Order $record): string => OrderResource::getUrl('view', $record))
->icon('heroicon-m-eye'),
]);
18 Replies
toeknee
toeknee3mo ago
chuck ->action(fn() => '') on the end, does it work now?
raheel3031
raheel3031OP3mo ago
What do you mean
toeknee
toeknee3mo ago
->actions([
Action::make('View Order')
->url(fn (Order $record): string => OrderResource::getUrl('view', $record))
->icon('heroicon-m-eye')
->action(fn() => ''),
]);
->actions([
Action::make('View Order')
->url(fn (Order $record): string => OrderResource::getUrl('view', $record))
->icon('heroicon-m-eye')
->action(fn() => ''),
]);
raheel3031
raheel3031OP3mo ago
Not working App\Filament\Widgets\LatestOrders::App\Filament\Widgets{closure}(): Argument #1 ($record) must be of type App\Filament\Widgets\Order, App\Models\Order given, called in C:\xampp\htdocs\nextxlecom\vendor\filament\support\src\Concerns\EvaluatesClosures.php on line 35
toeknee
toeknee3mo ago
So now it is working, but the binding is wrong. What are the actions on
raheel3031
raheel3031OP3mo ago
No it is not working
awcodes
awcodes3mo ago
you need use App\Models\Order; as the import at the top of the file
raheel3031
raheel3031OP3mo ago
No I already have that. That is not the issue Your sentence didn't complete
awcodes
awcodes3mo ago
can't think of any other reason it would be wanting an Order model in the Widgets namesapce.
toeknee
toeknee3mo ago
So
->actions([
Action::make('View Order')
->url(fn (\App\Models\Order $record): string => OrderResource::getUrl('view', $record))
->icon('heroicon-m-eye')
->action(fn() => ''),
]);
->actions([
Action::make('View Order')
->url(fn (\App\Models\Order $record): string => OrderResource::getUrl('view', $record))
->icon('heroicon-m-eye')
->action(fn() => ''),
]);
or add
use App\Models\Order;
use App\Models\Order;
at the top of the file.
awcodes
awcodes3mo ago
should also be explicit with the url data:
OrderResource::getUrl('view', ['record' => $record])
OrderResource::getUrl('view', ['record' => $record])
raheel3031
raheel3031OP3mo ago
On the top
namespace App\Filament\Widgets;

use App\Models\Order;
use App\Filament\Resources\OrderResource;
use Filament\Tables;
use Filament\Tables\Actions\Action;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;
namespace App\Filament\Widgets;

use App\Models\Order;
use App\Filament\Resources\OrderResource;
use Filament\Tables;
use Filament\Tables\Actions\Action;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;
awcodes
awcodes3mo ago
Does it work if you remove the type hint for the record?
raheel3031
raheel3031OP3mo ago
Yes It works now But I had that code at the start Thanks man
awcodes
awcodes3mo ago
then something is off with your namespacing.
raheel3031
raheel3031OP3mo ago
It is working now
awcodes
awcodes3mo ago
but if it works, then great
raheel3031
raheel3031OP3mo ago
Thanks man But on my other page I have the same issue But this solution doesn't work
namespace App\Filament\Resources\UserResource\RelationManagers;

use App\Filament\Resources\OrderResource;
use App\Models\Order;
use Filament\Actions\Modal\Actions;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Actions\Action;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
namespace App\Filament\Resources\UserResource\RelationManagers;

use App\Filament\Resources\OrderResource;
use App\Models\Order;
use Filament\Actions\Modal\Actions;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Actions\Action;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
->actions([
Tables\Actions\ActionGroup::make([
Action::make('View Order')
->url(fn (Order $record): string => OrderResource::getUrl('view', ['record' => $record]))
->color('info')
->icon('heroicon-o-eye'),,
Tables\Actions\DeleteAction::make(),
]),
->actions([
Tables\Actions\ActionGroup::make([
Action::make('View Order')
->url(fn (Order $record): string => OrderResource::getUrl('view', ['record' => $record]))
->color('info')
->icon('heroicon-o-eye'),,
Tables\Actions\DeleteAction::make(),
]),
Want results from more Discord servers?
Add your server