Jamie Cee
Jamie Cee
FFilament
Created by Jamie Cee on 3/13/2025 in #❓┊help
Saving relationships
So I realise the disableOptionWhen is for the preventing of selecting from the list, so don't think that is exactly what im after
10 replies
FFilament
Created by Jamie Cee on 3/13/2025 in #❓┊help
Saving relationships
No description
10 replies
FFilament
Created by Jamie Cee on 3/13/2025 in #❓┊help
Saving relationships
Ah yeah, that makes sense.\
10 replies
FFilament
Created by Jamie Cee on 3/13/2025 in #❓┊help
Saving relationships
->afterStateUpdated(
function ($state, $record, $context) {
dd($state, $record, $context);
if ($context == 'create') {
return $state;
}

if (
$record->isSuperAdmin()
&& $record == auth()->user()
) {
$state = array_merge($state, [RolesEnum::SUPER_ADMIN]);
}

return $state;
}
);
->afterStateUpdated(
function ($state, $record, $context) {
dd($state, $record, $context);
if ($context == 'create') {
return $state;
}

if (
$record->isSuperAdmin()
&& $record == auth()->user()
) {
$state = array_merge($state, [RolesEnum::SUPER_ADMIN]);
}

return $state;
}
);
My issue is that I cant seem to modify the logic before saving. I can remove the roles from the dropdown, but the saveRelationshipUsing where I have a dd() never gets hit
10 replies
FFilament
Created by Jamie Cee on 3/13/2025 in #❓┊help
Saving relationships
return Select::make('roles')
->preload()
->multiple()
->searchable()
->disabled(
function ($context, $record) {
if ($context == 'edit' && $record->trashed()) {
return true;
}

return false;
}
)
->disableOptionWhen(fn(string $value): bool => $value === RolesEnum::SUPER_ADMIN && !auth()->user()->isSuperAdmin())
->saveRelationshipsUsing(function ($record, $relationship, $values) {
dd($values, $record);
$record->syncRoles($values);
})
->relationship(
name: 'roles',
titleAttribute: 'name',
modifyQueryUsing: function ($query, $record) {
$roles = RolesEnum::allRoles();

if (auth()->user()) {
if ($record->isSuperAdmin() && $record == auth()->user()) {
unset($roles[array_search(RolesEnum::SUPER_ADMIN->value, $roles)]);
}

/* If user isn't a super admin, no role should have access to it */
if (!auth()->user()->isSuperAdmin()) {
unset($roles[array_search(RolesEnum::SUPER_ADMIN->value, $roles)]);
}

/* Users without the admin role, shouldnt be allowed to add/remove the admin role */
if (!auth()->user()->isAdmin()) {
unset($roles[array_search(RolesEnum::ADMIN->value, $roles)]);
}
}

return $query->whereIn('name', $roles);
}
)
return Select::make('roles')
->preload()
->multiple()
->searchable()
->disabled(
function ($context, $record) {
if ($context == 'edit' && $record->trashed()) {
return true;
}

return false;
}
)
->disableOptionWhen(fn(string $value): bool => $value === RolesEnum::SUPER_ADMIN && !auth()->user()->isSuperAdmin())
->saveRelationshipsUsing(function ($record, $relationship, $values) {
dd($values, $record);
$record->syncRoles($values);
})
->relationship(
name: 'roles',
titleAttribute: 'name',
modifyQueryUsing: function ($query, $record) {
$roles = RolesEnum::allRoles();

if (auth()->user()) {
if ($record->isSuperAdmin() && $record == auth()->user()) {
unset($roles[array_search(RolesEnum::SUPER_ADMIN->value, $roles)]);
}

/* If user isn't a super admin, no role should have access to it */
if (!auth()->user()->isSuperAdmin()) {
unset($roles[array_search(RolesEnum::SUPER_ADMIN->value, $roles)]);
}

/* Users without the admin role, shouldnt be allowed to add/remove the admin role */
if (!auth()->user()->isAdmin()) {
unset($roles[array_search(RolesEnum::ADMIN->value, $roles)]);
}
}

return $query->whereIn('name', $roles);
}
)
10 replies
FFilament
Created by Jamie Cee on 3/3/2025 in #❓┊help
Why is my content so wide
Only one I intentionally overridden was the login.blade.php as it was bveing a pain to pass the js functionality into the action for security keys
19 replies
FFilament
Created by Jamie Cee on 3/3/2025 in #❓┊help
Why is my content so wide
So just had a brief, I just temp renamed the simple.blade.php from resources/views/vendor, it fixes the view. So not sure what the issue entirely was as the simple.blade.php wasn't edited by me (that I can remember)
<x-filament-panels::layout.base :livewire="$livewire">
@props([
'after' => null,
'heading' => null,
'subheading' => null,
])

<div class="fi-simple-layout flex min-h-screen flex-col items-center">
@if (filament()->auth()->check())
<div class="absolute end-0 top-0 flex h-16 items-center gap-x-4 pe-4 md:pe-6 lg:pe-8">
@if (filament()->hasDatabaseNotifications())
@livewire(Filament\Livewire\DatabaseNotifications::class, ['lazy' => true])
@endif

<x-filament-panels::user-menu />
</div>
@endif

<div class="fi-simple-main-ctn flex w-full flex-grow items-center justify-center">
<main
@class([ 'fi-simple-main my-16 w-full bg-white px-6 py-12 shadow-sm ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10 sm:rounded-xl sm:px-12'
, match ($maxWidth ?? null) { 'xs'=> 'sm:max-w-xs',
'sm' => 'sm:max-w-sm',
'md' => 'sm:max-w-md',
'lg' => 'sm:max-w-lg',
'xl' => 'sm:max-w-xl',
'2xl' => 'sm:max-w-2xl',
'3xl' => 'sm:max-w-3xl',
'4xl' => 'sm:max-w-4xl',
'5xl' => 'sm:max-w-5xl',
'6xl' => 'sm:max-w-6xl',
'7xl' => 'sm:max-w-7xl',
default => 'sm:max-w-lg',
},
])
>
{{ $slot }}
</main>
</div>

{{ \Filament\Support\Facades\FilamentView::renderHook('panels::footer') }}
</div>
</x-filament-panels::layout.base>
<x-filament-panels::layout.base :livewire="$livewire">
@props([
'after' => null,
'heading' => null,
'subheading' => null,
])

<div class="fi-simple-layout flex min-h-screen flex-col items-center">
@if (filament()->auth()->check())
<div class="absolute end-0 top-0 flex h-16 items-center gap-x-4 pe-4 md:pe-6 lg:pe-8">
@if (filament()->hasDatabaseNotifications())
@livewire(Filament\Livewire\DatabaseNotifications::class, ['lazy' => true])
@endif

<x-filament-panels::user-menu />
</div>
@endif

<div class="fi-simple-main-ctn flex w-full flex-grow items-center justify-center">
<main
@class([ 'fi-simple-main my-16 w-full bg-white px-6 py-12 shadow-sm ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10 sm:rounded-xl sm:px-12'
, match ($maxWidth ?? null) { 'xs'=> 'sm:max-w-xs',
'sm' => 'sm:max-w-sm',
'md' => 'sm:max-w-md',
'lg' => 'sm:max-w-lg',
'xl' => 'sm:max-w-xl',
'2xl' => 'sm:max-w-2xl',
'3xl' => 'sm:max-w-3xl',
'4xl' => 'sm:max-w-4xl',
'5xl' => 'sm:max-w-5xl',
'6xl' => 'sm:max-w-6xl',
'7xl' => 'sm:max-w-7xl',
default => 'sm:max-w-lg',
},
])
>
{{ $slot }}
</main>
</div>

{{ \Filament\Support\Facades\FilamentView::renderHook('panels::footer') }}
</div>
</x-filament-panels::layout.base>
19 replies
FFilament
Created by Jamie Cee on 3/3/2025 in #❓┊help
Why is my content so wide
Apologies, got side tracked on another task yesterday, will give this a go later this afternoon and get back to you
19 replies
FFilament
Created by Jamie Cee on 3/3/2025 in #❓┊help
Why is my content so wide
Im guessing its the w-100 class in the main tag, but if thats there by default Im sure I've had it not go full width before
19 replies
FFilament
Created by Jamie Cee on 3/3/2025 in #❓┊help
Why is my content so wide
ran composer update this morning
19 replies
FFilament
Created by Jamie Cee on 3/3/2025 in #❓┊help
Why is my content so wide
Yeah
19 replies
FFilament
Created by Jamie Cee on 3/3/2025 in #❓┊help
Why is my content so wide
Yeah I have the overridden login form in the vendor path, I've ran all those steps except the current creating a new app.blade.php layout - would this still be needed even though im just using the page.simple template?
19 replies
FFilament
Created by Jamie Cee on 3/3/2025 in #❓┊help
Why is my content so wide
Yeah this is my main
fi-simple-main my-16 w-full bg-white px-6 py-12 shadow-sm ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10 sm:rounded-xl sm:px-12 sm:max-w-lg
fi-simple-main my-16 w-full bg-white px-6 py-12 shadow-sm ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10 sm:rounded-xl sm:px-12 sm:max-w-lg
I've ran npm run build, How am I checking if tailwind is configured properly?
19 replies
FFilament
Created by Jamie Cee on 3/3/2025 in #❓┊help
Why is my content so wide
I've also removed any custom classes that were on the blade, that made no difference
19 replies
FFilament
Created by Jamie Cee on 3/3/2025 in #❓┊help
Why is my content so wide
I cant see any full width section in my form, only place is for the actions, which is inside the form itself, (the boolean value in the class)
19 replies
FFilament
Created by Jamie Cee on 3/3/2025 in #❓┊help
Why is my content so wide
And the form in the Login class
protected function getForms(): array
{
return [
'form' => $this->form(
$this->makeForm()
->schema([
$this->getEmailFormComponent(),
$this->getPasswordFormComponent(),
$this->getRememberFormComponent(),
])
->statePath('data'),
),
];
}

protected function getEmailFormComponent(): Component
{
return TextInput::make('email')
->label(__('filament-panels::pages/auth/login.form.email.label'))
->email()
->required()
->autocomplete()
->autofocus()
->extraInputAttributes(['tabindex' => 1]);
}

protected function getPasswordFormComponent(): Component
{
return TextInput::make('password')
->label(__('filament-panels::pages/auth/login.form.password.label'))
->hint(filament()->hasPasswordReset()
? new HtmlString(Blade::render(
'<x-filament::link :href="filament()->getRequestPasswordResetUrl()">
{{ __(\'filament-panels::pages/auth/login.actions.request_password_reset.label\') }}
</x-filament::link>'
)) : null)
->password()
->autocomplete('current-password')
->required()
->extraInputAttributes(['tabindex' => 2]);
}

protected function getRememberFormComponent(): Component
{
return Checkbox::make('remember')
->label(__('filament-panels::pages/auth/login.form.remember.label'));
}
protected function getForms(): array
{
return [
'form' => $this->form(
$this->makeForm()
->schema([
$this->getEmailFormComponent(),
$this->getPasswordFormComponent(),
$this->getRememberFormComponent(),
])
->statePath('data'),
),
];
}

protected function getEmailFormComponent(): Component
{
return TextInput::make('email')
->label(__('filament-panels::pages/auth/login.form.email.label'))
->email()
->required()
->autocomplete()
->autofocus()
->extraInputAttributes(['tabindex' => 1]);
}

protected function getPasswordFormComponent(): Component
{
return TextInput::make('password')
->label(__('filament-panels::pages/auth/login.form.password.label'))
->hint(filament()->hasPasswordReset()
? new HtmlString(Blade::render(
'<x-filament::link :href="filament()->getRequestPasswordResetUrl()">
{{ __(\'filament-panels::pages/auth/login.actions.request_password_reset.label\') }}
</x-filament::link>'
)) : null)
->password()
->autocomplete('current-password')
->required()
->extraInputAttributes(['tabindex' => 2]);
}

protected function getRememberFormComponent(): Component
{
return Checkbox::make('remember')
->label(__('filament-panels::pages/auth/login.form.remember.label'));
}
19 replies
FFilament
Created by Jamie Cee on 2/19/2025 in #❓┊help
Calling a custom page from a function
Gotcha, cheers
27 replies
FFilament
Created by Jamie Cee on 2/19/2025 in #❓┊help
Calling a custom page from a function
Think Im just going about all this in the wrong way, and confusing myself
27 replies
FFilament
Created by Jamie Cee on 2/19/2025 in #❓┊help
Calling a custom page from a function
27 replies
FFilament
Created by Jamie Cee on 2/19/2025 in #❓┊help
Calling a custom page from a function
I dont think one was being passed, I wasnt sure how to set one up
27 replies