Mahdi
Mahdi
FFilament
Created by Mahdi on 4/13/2024 in #❓┊help
filament-shield: How to prevent a user from accessing the panel when he has no permissions?
this is work just in case the name of role is the same with panel name
public function canAccessPanel(Panel $panel): bool
{
$userRole = $this->roles()->first()->name;
$currentPanel = filament()->getCurrentPanel()->getId();
if ($currentPanel === $userRole)) {
return true;
}
return false;
}
public function canAccessPanel(Panel $panel): bool
{
$userRole = $this->roles()->first()->name;
$currentPanel = filament()->getCurrentPanel()->getId();
if ($currentPanel === $userRole)) {
return true;
}
return false;
}
3 replies
FFilament
Created by Mahdi on 4/10/2024 in #❓┊help
FileUpload with relations
For example If User has a Profile How to use FileUpload with Relations for saving multiple files for every user using ->multiple()
profile table
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->json('attachments')->nullable(); // for FileUpload multiable
// Other Columns
$table->timestamps();
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->json('attachments')->nullable(); // for FileUpload multiable
// Other Columns
$table->timestamps();
Profile Model
protected $casts = [
'attachments' => 'array'
];

public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
protected $casts = [
'attachments' => 'array'
];

public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
User Model
public function profile(): HasOne
{
return $this->HasOne(Profile::class);
}
public function profile(): HasOne
{
return $this->HasOne(Profile::class);
}
User resource
->schema([
FileUpload::make('attachments'))
->multiple(),
]),
->schema([
FileUpload::make('attachments'))
->multiple(),
]),
2 replies
FFilament
Created by Mahdi on 10/23/2023 in #❓┊help
Is it possible to have multi-database tenancy
If it's possible, it would be nice to have documentation .
15 replies