Export excel for custom model
I am using Custom Model UsersAdmin
file is showing in notification for download but when i clicking download button given error
9 Replies
Sounds like a permissions issue to me... did you link storage too?
yes I did
Are you the user who started the download?
Have you created an Export Policy Class?
No
Ok thanks I try
I am using Laravel 11
Not working still giving error
first, active your windows. LOL
what about the logic in the view method?
ok sorry for window active message
I just want to download excel file. and I am using UsersAmin model for and Admin Panel Provider of filament is
<?php
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
->login(Login::class)
->authGuard('admin')
->brandName('Noritz PROCard Admin Control Panel')
->colors([
'primary' => Color::Red,
])
->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\Filament\Pages')
->pages([
Pages\Dashboard::class,
])
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\Filament\Widgets')
->widgets([
Widgets\AccountWidget::class,
Widgets\FilamentInfoWidget::class,
])
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
])
->databaseNotifications()
->authMiddleware([
Authenticate::class,
]);
}
}
and app service provider
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
// protected $policies = [
// Export::class => ExportPolicy::class,
// ];
public function register(): void { $this->app->bind(Authenticatable::class, UsersAdmin::class); } <?php namespace App\Policies; use App\Models\UsersAdmin; use Filament\Actions\Exports\Models\Export; class ExportPolicy { public function view(UsersAdmin $user, Export $export): bool { dd('sssssssssssssss'); return $export->user()->is($user); } }
public function register(): void { $this->app->bind(Authenticatable::class, UsersAdmin::class); } <?php namespace App\Policies; use App\Models\UsersAdmin; use Filament\Actions\Exports\Models\Export; class ExportPolicy { public function view(UsersAdmin $user, Export $export): bool { dd('sssssssssssssss'); return $export->user()->is($user); } }