marianov24
marianov24
Explore posts from servers
FFilament
Created by marianov24 on 5/23/2024 in #❓┊help
Select using getSearchResultsUsing with preload
Hi i follow this Tricks :
https://v2.filamentphp.com/tricks/render-html-in-select-options
https://v2.filamentphp.com/tricks/render-html-in-select-options
I try use getSearchResultsUsing and getOptionLabelUsing. I want use preload too, but it's not working. If i use options and getOptionlabelUsing, preload works but searchable not. (when i use this, i comment ->where)
Select::make('product')->label('Eventos')
//->options(function(){
->getSearchResultsUsing( function(string $search) {
$user = auth()->user();

if($user->products()->whereBelongsTo(Filament::getTenant())->whereRelation('performances','start','>=',now()->subMonths(8))->count() > 0)
{
$products =
$user->products()->whereBelongsTo(Filament::getTenant())
->whereRelation('performances','start','>=',now()->subMonths(8))
->where('internal_name','like',"%{$search}%")
->get();
}else{
$products =
Product::whereBelongsTo(Filament::getTenant())
->whereRelation('performances','start','>=',now()->subMonths(8))
->where('internal_name','like',"%{$search}%")
->get();
}
return $products->mapWithKeys(function ($product) {
return [$product->stx_id => static::getCleanOptionString($product)];
})->toArray();

})
->getOptionLabelUsing(function ($value): string {
$product = Product::find($value);

return static::getCleanOptionString($product);
})
->preload()
->allowHtml()
->searchable()
Select::make('product')->label('Eventos')
//->options(function(){
->getSearchResultsUsing( function(string $search) {
$user = auth()->user();

if($user->products()->whereBelongsTo(Filament::getTenant())->whereRelation('performances','start','>=',now()->subMonths(8))->count() > 0)
{
$products =
$user->products()->whereBelongsTo(Filament::getTenant())
->whereRelation('performances','start','>=',now()->subMonths(8))
->where('internal_name','like',"%{$search}%")
->get();
}else{
$products =
Product::whereBelongsTo(Filament::getTenant())
->whereRelation('performances','start','>=',now()->subMonths(8))
->where('internal_name','like',"%{$search}%")
->get();
}
return $products->mapWithKeys(function ($product) {
return [$product->stx_id => static::getCleanOptionString($product)];
})->toArray();

})
->getOptionLabelUsing(function ($value): string {
$product = Product::find($value);

return static::getCleanOptionString($product);
})
->preload()
->allowHtml()
->searchable()
3 replies
FFilament
Created by marianov24 on 12/21/2023 in #❓┊help
Custom Page with HasFiltersForm with submit button
How can insert a submit button to apply filters and only apply when click on submit and not on every changes from fields. I could show on view page, but it's not working with the form.
3 replies
TLCTuto's Laravel Corner
Created by marianov24 on 12/20/2023 in #💡filament
Clean filters
I create custom pages to show 2 or 3 widgets, all has
use HasFiltersForm;
use HasFiltersForm;
I need when navigate and comeback to the pages, the filters set null. I try: mount $this->filters = null; on custom page, not working mount $this->filters = null; on widget and got an error cannot mutate filters. How can i solve this?
4 replies
FFilament
Created by marianov24 on 12/19/2023 in #❓┊help
clean filters from Dashboard
I'm using use
HasFiltersForm;
public function filtersForm(Form $form): Form
{ ....... }
HasFiltersForm;
public function filtersForm(Form $form): Form
{ ....... }
I need clean filters went enter to dashboard page.
4 replies
FFilament
Created by marianov24 on 5/31/2023 in #❓┊help
List From a Model - Form and Save from another Model with Relationship
I have a table with Products (I have all the basic info) and another table ExtraFieldProduct (extra fields for the products). What I would need is to list the products in the table, but when I click on a record send the id to the ExtraFieldProduct Form, set the id to product_id and then fill in the form to create or edit. Thanks!!!
6 replies
FFilament
Created by marianov24 on 5/5/2023 in #❓┊help
disable clickable row with getTableRecordActionUsing() not working
I want to disable clickable rows, so i follow the docs:
https://filamentphp.com/docs/2.x/tables/getting-started#clickable-rows
https://filamentphp.com/docs/2.x/tables/getting-started#clickable-rows
I add to the Resoure:
protected function getTableRecordActionUsing(): ?Closure
{
return null;
}
protected function getTableRecordActionUsing(): ?Closure
{
return null;
}
and try too:
protected function getTableRecordUrlUsing(): ?Closure
{
return null;
}
protected function getTableRecordUrlUsing(): ?Closure
{
return null;
}
But is not working
6 replies
FFilament
Created by marianov24 on 3/21/2023 in #❓┊help
Form keep loading
I have one Form that's keep loading... finish with timeout. This form is only to view information, so is a view. I remove, all the RelationManager and on the form make simple a Select:
Select::make('contact_id')->label('Contact')
->options(function (callable $get) {

return Contact::find($get('contact_id'))->pluck('email', 'id');
}),
Select::make('contact_id')->label('Contact')
->options(function (callable $get) {

return Contact::find($get('contact_id'))->pluck('email', 'id');
}),
the others fields are from the model. I use MySQL and the table has 159736 records. I have another thable with more records and don't have any problem. How can i debug this?
10 replies
FFilament
Created by marianov24 on 3/5/2023 in #❓┊help
Relation Manager Resource with pivot - Custom Attach
Hi guys, i create a Relation Manager Resource with pivot. Information: -> Invoice -> it's the Main Resource -> Performance -> it's the Relation Manager Resource -> they have Many to Many relationship. -> it's work, but i need make a change. * I have Product table that has Many Performance, So i need on the popup show a Select for Products, when products Select filter the Performance :
->headerActions([
AttachAction::make()->label('Agregar')
->form(fn (AttachAction $action): array => [
//$action->getRecordSelect(),

Forms\Components\Select::make('product_id')
->relationship('product','external_name')
->afterStateUpdated(fn (callable $set) => $set ('start',null))
->reactive()
->searchable()->required(),
Forms\Components\Select::make('start')
->options(function (callable $get){

$product = Product::find($get('product_id'));
if (!$product)
{
return [];
}
return $product->performances()->pluck('start','id');
})->required()

]),
])
->headerActions([
AttachAction::make()->label('Agregar')
->form(fn (AttachAction $action): array => [
//$action->getRecordSelect(),

Forms\Components\Select::make('product_id')
->relationship('product','external_name')
->afterStateUpdated(fn (callable $set) => $set ('start',null))
->reactive()
->searchable()->required(),
Forms\Components\Select::make('start')
->options(function (callable $get){

$product = Product::find($get('product_id'));
if (!$product)
{
return [];
}
return $product->performances()->pluck('start','id');
})->required()

]),
])
The form works but when a click on Attach i got an error:
Undefined array key "recordId"
Undefined array key "recordId"
I imagine that to solve this I should use:
Relation Manager Resource with pivot - Custome Attach
Relation Manager Resource with pivot - Custome Attach
But I do not know how to do it
9 replies