Grogu
Grogu
FFilament
Created by Grogu on 2/22/2025 in #❓┊help
Unique validation on 2 or more columns
In my model migration, I have a unique constraint between 2 columns:
$table->unique(['column_1', 'column_2'])
$table->unique(['column_1', 'column_2'])
How do I enforce this in my filament resource when creating or editing? Thanks!
1 replies
FFilament
Created by Grogu on 2/15/2025 in #❓┊help
Relation manager not allowing duplicates
Hi there, I have roles and users in my app. In the pivot table, there is an optional "assignable" morph, so that the role can be against another entity, such as my Location model... "A user has a role for this location..." I should be able to attach multiple roles to a user, as long as the assignable is different, so the user can have the same role for multiple locations, but I can't seem to figure out how to achieve this? In the relation manager attach action, the role is removed from the selection as soon as it's been assigned once. If I hard code the role options to always displace all, if i attach multiple roles to a user with different "assignables", when I "detach" one record, it detaches all relations which have the same user_id, role_id... Any help? I've attached some files, and my relationships include the id pivot:
// user model role relation
public function roles(): BelongsToMany
{
return $this->belongsToMany(Role::class)
->withPivot('id', 'assignable_type', 'assignable_id')
->withTimestamps();
}

// role model users relation
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class)
->withPivot('id', 'assignable_type', 'assignable_id')
->withTimestamps();
}
// user model role relation
public function roles(): BelongsToMany
{
return $this->belongsToMany(Role::class)
->withPivot('id', 'assignable_type', 'assignable_id')
->withTimestamps();
}

// role model users relation
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class)
->withPivot('id', 'assignable_type', 'assignable_id')
->withTimestamps();
}
Thanks!
2 replies
FFilament
Created by Grogu on 2/12/2025 in #❓┊help
How to set the default action on table row click
Hi all! It seems an obvious one, but I can't seem to figure out how filament determines the default action when a table row is clicked. I have 2 resources, both have View and Edit actions in the $table->actions() array, yet when clicking a row in 1 of the resources, I am taken to the edit page and the other resource goes to the view page? Thanks!
7 replies