Davide Cariola
Davide Cariola
FFilament
Created by Davide Cariola on 7/2/2024 in #❓┊help
Filter for calculated field
No description
6 replies
FFilament
Created by Davide Cariola on 6/23/2024 in #❓┊help
Table Filter for Repeater Json Column
No description
6 replies
FFilament
Created by Davide Cariola on 6/16/2024 in #❓┊help
Filter's query returns collection but table stays empty
Hi everyone, I am experiencing strange behaviour from one of my filters. I have created a mix-max field, where I basically go and filter my records by minimum and maximum price. The query works through a normal when, with 2 different options: if a minimum price is entered and if a maximum price is entered. This way, when the maximum price was deleted from the input, the table returned nothing. So I thought of creating a third option: i.e. if the maximum price is null it returns all records with price <= the maximum possible price (obtained through a db query), but nothing has changed. I've done some dumps and actually the code enters the when and, doing a dump of $query, the where exists; doing a dump of $query->get() I get the records I expect (i.e. all of them); the problem is that anyway the table remains empty.
4 replies
FFilament
Created by Davide Cariola on 6/14/2024 in #❓┊help
Customize Filter style
No description
5 replies
FFilament
Created by Davide Cariola on 6/1/2024 in #❓┊help
Go to different step based on field value
Hi! I'm working on a wizard and I have to redirect the user to different steps based on the value of a specific field. Could not find anything in the docs or here. Every kind of hint will be pure gold. In the docs I found this: https://filamentphp.com/docs/3.x/forms/layout/wizard#customizing-the-wizard-action-objects and I thought it could be useful, but for now I can't figure out how.
3 replies
FFilament
Created by Davide Cariola on 5/29/2024 in #❓┊help
Hide create button in a form with wizard
No description
6 replies
FFilament
Created by Davide Cariola on 10/21/2023 in #❓┊help
Repeater MorphToMany
Hi everyone! I'm having a rough time with managing a MorphToMany relationship with a repeater. I'm currently managing permissions, roles and users. Model/Permission.php
public function roles(): MorphToMany
{
return $this->morphedByMany(Role::class, 'grantable');
}

public function users(): MorphToMany
{
return $this->morphedByMany(User::class, 'grantable');
}
public function roles(): MorphToMany
{
return $this->morphedByMany(Role::class, 'grantable');
}

public function users(): MorphToMany
{
return $this->morphedByMany(User::class, 'grantable');
}
Model/User.php:
public function permissions(): MorphToMany
{
return $this->morphToMany(Permission::class, 'grantable');
}
public function permissions(): MorphToMany
{
return $this->morphToMany(Permission::class, 'grantable');
}
Model/Role.php:
public function permissions(): MorphToMany
{
return $this->morphToMany(Permission::class, 'grantable');
}
public function permissions(): MorphToMany
{
return $this->morphToMany(Permission::class, 'grantable');
}
Logic works fine, except the Repeater. I followed this documentation: https://filamentphp.com/docs/3.x/forms/fields/repeater#integrating-with-a-belongstomany-eloquent-relationship and created the pivot class:
class Grantable extends Pivot
{
use HasFactory;

protected $table = 'grantables';

public function permission(): BelongsTo
{
return $this->belongsTo(Permission::class);
}

public function role(): BelongsTo
{
return $this->belongsTo(Role::class);
}
}
class Grantable extends Pivot
{
use HasFactory;

protected $table = 'grantables';

public function permission(): BelongsTo
{
return $this->belongsTo(Permission::class);
}

public function role(): BelongsTo
{
return $this->belongsTo(Role::class);
}
}
and in Model/Permission.php:
public function grantables(): HasMany
{
return $this->hasMany(Grantable::class);
}
public function grantables(): HasMany
{
return $this->hasMany(Grantable::class);
}
2 replies
FFilament
Created by Davide Cariola on 10/20/2023 in #❓┊help
Notification instead of 403 error page
Hi everyone! As I'm working with roles and permissions, I have a lot of action that can and cannot be done depending on the user and its role. Is it possible to get that, instead of triggering a 403 error (from a gate or other policy), a notification with the message "Unauthorized" is triggered? I imagine it can be done by managing Notifications in the various actions, but I would prefer to write it once and have it work for all cases. Thank you very much for the support!
9 replies
FFilament
Created by Davide Cariola on 10/18/2023 in #❓┊help
Open a modal or slide over with table Action
No description
6 replies
FFilament
Created by Davide Cariola on 10/12/2023 in #❓┊help
Get record values in Livewire component with Filament Table
Hello everyone. I have inserted a Filament table inside a Livewire component. One of the fields is of type TextInputColumn, but I would like the same to have the disabled() option at a certain condition, which though depends on the value of the selected record. Can this be done? Unfortunately, I could not find any details about it. Here's my code and my idea:
TextInputColumn::make('name')
->label('Nome del ruolo')
->searchable()
->disabled(
! auth()->role->checkPermission('ruoli-modifica-ruolo-' . $record->slug)
),
TextInputColumn::make('name')
->label('Nome del ruolo')
->searchable()
->disabled(
! auth()->role->checkPermission('ruoli-modifica-ruolo-' . $record->slug)
),
Obviously, for now $record->slug returns an error. Thank you!
6 replies
FFilament
Created by Davide Cariola on 10/11/2023 in #❓┊help
EditAction and ViewAction doesn't work on livewire-table
Hi everyone! I used a livewire-table to show different roles. I'm having issues with the EditAction and ViewAction: when I click on edit, the loader starts and, when finished, I get a "saved" notification. When I click on view, nothing happens. The wierd thing is that the DeleteAction works as intended. This is my code:
class RoleManager extends Component implements HasForms, HasTable, HasActions
{
...

public static function table(Table $table): Table
{
return $table
->query(Role::query())
->columns([
TextColumn::make('id')
->sortable(),
TextInputColumn::make('name')
->label('Nome del ruolo')
->searchable(),
TextColumn::make('description')
->label('Descrizione')
->searchable()
->toggleable(),
])
->reorderable('order')
->reorderRecordsTriggerAction(
fn (Action $action, bool $isReordering) => $action
->button()
->label($isReordering ? 'Conferma' : 'Riordina'),
)
->defaultSort('order')
->striped()
->filters([
//
])
->actions([
EditAction::make()
->label('Modifica'),
DeleteAction::make()
->label('Cancella'),
ViewAction::make(),

])
->bulkActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
])
->headerActions([
//
]);
}
...
}
class RoleManager extends Component implements HasForms, HasTable, HasActions
{
...

public static function table(Table $table): Table
{
return $table
->query(Role::query())
->columns([
TextColumn::make('id')
->sortable(),
TextInputColumn::make('name')
->label('Nome del ruolo')
->searchable(),
TextColumn::make('description')
->label('Descrizione')
->searchable()
->toggleable(),
])
->reorderable('order')
->reorderRecordsTriggerAction(
fn (Action $action, bool $isReordering) => $action
->button()
->label($isReordering ? 'Conferma' : 'Riordina'),
)
->defaultSort('order')
->striped()
->filters([
//
])
->actions([
EditAction::make()
->label('Modifica'),
DeleteAction::make()
->label('Cancella'),
ViewAction::make(),

])
->bulkActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
])
->headerActions([
//
]);
}
...
}
I also tried to use the getPages method from the resource. Thank you so much for the help.
3 replies
FFilament
Created by Davide Cariola on 10/4/2023 in #❓┊help
relation manager authorization
Hi everyone! How can I authorize a user to interact with a Relation Manager? I have a project where roles are related to permissions, and in the edit of the permissions, I inserted a RolesRelationManager. By implementing a RolePolicy (even setting to all simply return true), I no longer see the structure in the permission edit. In the documentation I cannot find how I can handle this permission. Thank you so much for every help
2 replies
FFilament
Created by Davide Cariola on 10/3/2023 in #❓┊help
Daisy UI on a Livewire component to use in a custom page
Hi everyone! I'm trying to apply base tailwind classes and Daisy UI ones in a Livewire component used in a custom page. I've read the previous conversations about it, created a custom theme, but I can't seem to make it work. This is my vite.config.js:
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js', 'resources/css/filament/admin/theme.css'],
refresh: true,
}),
],
});
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js', 'resources/css/filament/admin/theme.css'],
refresh: true,
}),
],
});
This is my tailwind.config.js:
import preset from '../../../../vendor/filament/filament/tailwind.config.preset'

export default {
presets: [preset],
content: [
'./app/Filament/**/*.php',
'./resources/views/filament/**/*.blade.php',
'./vendor/filament/**/*.blade.php',
],
plugins: [require("daisyui")]
}
import preset from '../../../../vendor/filament/filament/tailwind.config.preset'

export default {
presets: [preset],
content: [
'./app/Filament/**/*.php',
'./resources/views/filament/**/*.blade.php',
'./vendor/filament/**/*.blade.php',
],
plugins: [require("daisyui")]
}
My AdminPanelProvider: ])->viteTheme('resources/css/filament/admin/theme.css'); My component:
<div class="bg-orange-500">
<button class="btn btn-primary">Primary</button>

<hr>

This is the table!

{{ $this->table }}
</div>
<div class="bg-orange-500">
<button class="btn btn-primary">Primary</button>

<hr>

This is the table!

{{ $this->table }}
</div>
Both bg-orange-500 (default tailwind) and btn btn-primary (daisy ui) don't work. I've run npm run build and have npm run dev active. I receive the daisy ui message when building the assets. I also notice that if in my tailwind.config.js lives plugins: [require("daisyui")], come colors from the side bar disappears Thank you so much for every help.
4 replies
FFilament
Created by Davide Cariola on 10/2/2023 in #❓┊help
Change the table content
No description
25 replies