onursahindur
Is it possible to add a default emptyStateHeading for all the tables?
Hello I know how to edit emptyStateHeading explained here https://filamentphp.com/docs/3.x/tables/empty-state
But I want to ask if it is possible to give a default title for every table I use in system? I want to show for example "No content" for all the tables I use.
4 replies
Select field with Checkbox
Hello again all,
I want to disable a basic select field when checkbox is checked, I made both components reactive and getting the checkbox component's state in disabled closure correctly, even Select disabled function gets called after checkbox updated
But the even if checkbox disabled state returning false, select disabled state is not changing. It stays same as if the first page load state. Am I missing something?
Here is my code;
Checkbox::make('send_all_users')
->label('Send to everyone')
->inline()
->reactive(),
Select::make('branch_ids')
->reactive()
->label('Choose branch ids')
->hint('Seçili şube üyelerine gönderin')
->multiple()
->searchable()
->options(fn () =>
Branch::where('corp_id', $authUser->corp_id)
->get()
->pluck('title', 'id')
)
->disabled(function (Closure $get) {
error_log('send_all_users: ' . !boolval($get('send_all_users')));
return !boolval($get('send_all_users'));
}),
5 replies
Select field hasMany relation
Hello all, I am trying to achieve a select field relation with a hasMany relation.
I have one Model called
Content
and one model ContentVisibility
ContentVisibility
holds a content_id
, with a type
field which can be either be BRANCH or COMMUNITY
in Content.php I have relations defined as;
public function visibilities(): HasMany {
return $this->hasMany(ContentVisibility::class, 'content_id', 'id');
}
also in ContentVisibility.php as;
public function content(): BelongsTo {
return $this->belongsTo(Content::class, 'id', 'content_id');
}
I want to Make two select fields in "EditContent" resource which edits the relations.
I came up like these;
Select::make('branch_visibility_id')
->label('Show only to this branches...')
->multiple()
->options( ... )
->relationship('visibilities', fn (Builder $query) => $query->where('type', ContentVisibilityTypeEnum::BRANCH))
->searchable(),
Select::make('community_visibilities')
->label('Show only to this communities...')
->multiple()
->options(...)
->relationship('visibilities', fn (Builder $query) => $query->where('type', ContentVisibilityTypeEnum::COMMUNITY))
->searchable(),
But as far as I understand "relationship" for select searches for a BelongsToMany
relation, which I think it is not suitable for this situation.
Did I missed something?
Thanks.13 replies
SpatieMediaLibraryPlugin with getTableQuery()
Hello all,
I am using SpatieMediaLibraryPlugin for media collections.
I have a user model where admin's can hold PDF, Word or Excel documents for a specific user.
I want to show these files on a table but could not find how I can query the Media class in getTableQuery() function.
Does anyone know a trick for it?
Thanks.
4 replies