Matteo De Blasis
Matteo De Blasis
FFilament
Created by Matteo De Blasis on 8/22/2024 in #❓┊help
Custom redirect after login from livewire component
Hello everyone! I want to redirect to the right panel based on user role. I have two panels: -- Role1Panel -- Role2Panel and i have three type of users: -- admin user: he have to redirect to Role1Panel but he can switch the panel (i use Panel Switch by Bezhan Salleh) -- role1 user: he have to redirect to Role1Panel and he cannot switch the panel -- role2 user: he have to redirect to Role2Panel and he cannot switch the panel Each users have a panel column for identify own panel. I want the"/login" route, i don't need the default login routes of both panels, so i create a Login Livewire component that it use "cleaned" authenticate function, copied by Filament Login page. Following this guide: https://v2.filamentphp.com/tricks/customize-redirect-after-admin-login, i create a custom LoginResponse class that it use the panel user column for redirect. The first time login everything works but from there on I am always redirected to the panel of the first login and i don't know why. This is my authenticate function: public function authenticate(){ if (! Filament::auth()->attempt(['email' => $this->email, 'password' => $this->password], true)) { $this->throwFailureValidationException(); } session()->regenerate(); return app(LoginResponse::class); } And my LoginResponse class: namespace App\Http\Responses; use Filament\Http\Responses\Auth\Contracts\LoginResponse as LoginResponseContract; class LoginResponse implements LoginResponseContract { /** * @param $request * @return \Illuminate\Http\RedirectResponse */ public function toResponse($request) { $panel = $request->user()->panel ?: 'ramerino'; return redirect()->intended("/$panel"); } } thanks in advance!
4 replies
FFilament
Created by Matteo De Blasis on 3/15/2024 in #❓┊help
ExportAction problem
Is it possible to export file with multiple sheet, with ExportAction?
8 replies
FFilament
Created by Matteo De Blasis on 3/5/2024 in #❓┊help
ImageColumn make Table rendering so slow
This is my situation: I have db table (ads) without column for image, for retrieve ad's images i have an attribute that return me all links for ad's folder on s3. In my table i want to show image ad thumbnail. My attribute (i cannot change this code):
public function getPhotoThumbnailLinkAttribute()
{
return array_map(function ($item) {
return Storage::url($item);
}, Storage::files('ads/'.$this->id.'/thumbnail/'));
}
public function getPhotoThumbnailLinkAttribute()
{
return array_map(function ($item) {
return Storage::url($item);
}, Storage::files('ads/'.$this->id.'/thumbnail/'));
}
and i set ImageColum like that:
Tables\Columns\ImageColumn::make('photos')->extraImgAttributes(fn(Ad $record): array => [
'src' => head($record->photo_thumbnail_link),
'loading' => 'lazy'
]),
Tables\Columns\ImageColumn::make('photos')->extraImgAttributes(fn(Ad $record): array => [
'src' => head($record->photo_thumbnail_link),
'loading' => 'lazy'
]),
But Table is rendered only when all thumbnails are loaded and "ready" to be displayed. Is there any way to speed up the table loading? Thanks in advance
2 replies
FFilament
Created by Matteo De Blasis on 12/13/2023 in #❓┊help
Print MorpthTo relation in table widget
No description
2 replies