Amiejah
Logout action in a livewire component
I'm using the actions as a Livewire component to display a Sidepanel. However trying to figure out on how to create a "logout" action. I'm thinking of setting an extraAttribute (onClick) which will trigger a JS function to submit a form (logout form).
Something like this:
Is there no better option than this?
Thank you
2 replies
Custom (profile) page re-using the EditUser (editRecord) resource
I'm trying to create a profile page in which the user can easily manager it's own user information. Instead of creating a custom page, and load the resources forms/tables etc. I wanted it to contain the same configuration as the EditUser resource.
Would this be a good way to go?
class Profile extends EditUser
{
use InteractsWithAuthentication;
protected static ?string $navigationIcon = 'heroicon-o-user';
public function mount(int|string|null $record = null): void
{
$this->record = $this->resolveRecord(
static::getUser()->getRouteKey()
);
$this->authorizeResourceAccess();
$this->fillForm();
$this->previousUrl = url()->previous();
}
public function getBreadcrumbs(): array
{
return [];
}
public static function getUrl(array $parameters = [], bool $isAbsolute = true, ?string $panel = null, ?Model $tenant = null): string
{
$parameters['tenant'] ??= ($tenant ?? Filament::getTenant());
return route(static::getRouteName($panel), $parameters, $isAbsolute);
}
/**
* This will make sure that the page is registeren while not being part of the (User)Resource
*
* @param string|null $panel
* @return string
*/
public static function getRouteName(?string $panel = null): string
{
$panel ??= Filament::getCurrentPanel()->getId();
return (string) str(static::getSlug())
->replace('/', '.')
->prepend("filament.{$panel}.pages.");
}
public static function shouldRegisterNavigation(array $parameters = []): bool
{
return static::getResource()::canEdit(
static::getUser()
);
}
public static function authorizeResourceAccess(): void
{
abort_unless(static::getResource()::canEdit(static::getUser()), 403);
}
}
3 replies