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
toeknee4mo ago
chuck ->action(fn() => '') on the end, does it work now?
raheel3031
raheel3031OP4mo ago
What do you mean
toeknee
toeknee4mo 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
raheel3031OP4mo 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
toeknee4mo ago
So now it is working, but the binding is wrong. What are the actions on
raheel3031
raheel3031OP4mo ago
No it is not working
awcodes
awcodes4mo ago
you need use App\Models\Order; as the import at the top of the file
raheel3031
raheel3031OP4mo ago
No I already have that. That is not the issue Your sentence didn't complete
awcodes
awcodes4mo ago
can't think of any other reason it would be wanting an Order model in the Widgets namesapce.
toeknee
toeknee4mo 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
awcodes4mo ago
should also be explicit with the url data:
OrderResource::getUrl('view', ['record' => $record])
OrderResource::getUrl('view', ['record' => $record])
raheel3031
raheel3031OP4mo 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
awcodes4mo ago
Does it work if you remove the type hint for the record?
raheel3031
raheel3031OP4mo ago
Yes It works now But I had that code at the start Thanks man
awcodes
awcodes4mo ago
then something is off with your namespacing.
raheel3031
raheel3031OP4mo ago
It is working now
awcodes
awcodes4mo ago
but if it works, then great
raheel3031
raheel3031OP4mo 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