SirAlyon
SirAlyon
FFilament
Created by SirAlyon on 5/24/2024 in #❓┊help
Help Needed with ToggleButtons in Filament Form
Hi everyone, I'm struggling with an issue that I believe (and hope) has a simple solution. I have a custom Livewire component where I'm using the Filament 3 form.
Fieldset::make('Allocazione')
->schema([
ToggleButtons::make('allocazione')
->label('')
->multiple()
->required()
->markAsRequired(false)
->options([
'obbligazionaria' => 'Obbligazionaria',
'prudente' => 'Prudente',
'moderata' => 'Moderata',
'azionaria' => 'Azionaria',
'libera' => 'Libera',
])
->rules([new Allocazione])
->inline(),
])
->columnSpan(2),
Fieldset::make('Allocazione')
->schema([
ToggleButtons::make('allocazione')
->label('')
->multiple()
->required()
->markAsRequired(false)
->options([
'obbligazionaria' => 'Obbligazionaria',
'prudente' => 'Prudente',
'moderata' => 'Moderata',
'azionaria' => 'Azionaria',
'libera' => 'Libera',
])
->rules([new Allocazione])
->inline(),
])
->columnSpan(2),
The problem lies with the ToggleButtons. As you can see, I have 5 options. The first 4 (obbligazionaria, prudente, moderata, azionaria) can be selected freely, but they exclude the last one (libera) and vice versa. I would like to disable "libera" as soon as one of the other 4 is clicked, and disable the other 4 as soon as "libera" is clicked. I'm pretty sure this can be done. I've tried several methods, but none have worked properly. Could you help me out? Thanks!
24 replies
FFilament
Created by SirAlyon on 5/23/2024 in #❓┊help
CheckboxList Issue on Custom Livewire page
Hi everyone, I'm having an issue using a CheckboxList on a custom Livewire component. I've only imported the Filament forms as I don't need the entire interface. I'm building a wizard with several steps and some inputs/checkboxes within. Here is the example code:
class AstiWizardComponent extends Component implements HasForms, HasActions
{
use InteractsWithActions;

use InteractsWithForms;

public ?array $data = [];
public $importoMultilinea;
//public $allocazione; <---- IT CAUSE ERROR :(
class AstiWizardComponent extends Component implements HasForms, HasActions
{
use InteractsWithActions;

use InteractsWithForms;

public ?array $data = [];
public $importoMultilinea;
//public $allocazione; <---- IT CAUSE ERROR :(
CheckboxList::make('allocazione')
->options([
'obbligazionaria' => 'Obbligazionaria',
'prudente' => 'Prudente',
'moderata' => 'Moderata',
'azionaria' => 'Azionaria',
'libera' => 'Linera',
])
->reactive()
->columns(5)
CheckboxList::make('allocazione')
->options([
'obbligazionaria' => 'Obbligazionaria',
'prudente' => 'Prudente',
'moderata' => 'Moderata',
'azionaria' => 'Azionaria',
'libera' => 'Linera',
])
->reactive()
->columns(5)
I have mainly two problems: When using the "public $allocazione" variable in the Livewire component, clicking on a single checkbox marks all of them as active. However, if I don't use this variable, the individual checkbox works correctly, but when I click "next" to go to the next step, I receive the error: "No property found for validation: [allocazione]". Could you please help me understand what I am doing wrong? Thank you!
3 replies
FFilament
Created by SirAlyon on 2/29/2024 in #❓┊help
Customizing Filament Export Action
Hello everyone, I would need some help with an issue I'm facing regarding the export action in Filament. Currently, I have a resource where I allow exporting using Filament's standard export action. After several attempts, I managed to get database notifications working as well, all very nice. Unfortunately, I can't figure out how to override/modify the link for downloading the file. I have a customized setup for the application's storage (it's not located internally but at a specific path on the Linux machine hosting my app). Using route:list, I noticed that there's a Filament route 'filament/exports/{id}/download' that is definitely used for returning the file to download, but I can't seem to access it or override it. Could you help me in some way? I could solve it in different ways; I just need to override the link with my custom one pointing to a route I created (already existing and working for other downloads). Thank you very much!
43 replies
FFilament
Created by SirAlyon on 2/16/2024 in #❓┊help
Trouble with Relation Manager for Many-to-Many Relationship
Hello everyone, I'm experiencing issues with managing the Filament relation manager. Currently, I have two Laravel models related with a many-to-many relationship. I've followed the steps in the documentation, but I can't understand why I'm not getting any results. The manager table is not displayed in the create or edit views of the resource, and all this happens without triggering any errors. I'll paste the formatted code that's needed for reference. I'm pretty confident the issue lies on the Filament side, as I've tested the relationship with Laravel Tinker, and it works correctly. I'm not getting any results in the edit/create views of the resource. Can anyone help me figure out what's going wrong? KiidPdfPattern Model:
class KiidPdfPattern extends Model
{
use HasFactory;

public $timestamps = false;

protected $table = 'kiid_dati_tipo';
protected $primaryKey = 'lunivid';
protected $guarded = [];

public function kiidMailPdfs(): BelongsToMany
{
return $this->belongsToMany(KiidMailPdf::class, 'kiid_mail_pdf_kiid_dati_tipo', 'kiid_dati_tipo_lunivid', 'kiid_mail_pdf_lunivid');
}
}
class KiidPdfPattern extends Model
{
use HasFactory;

public $timestamps = false;

protected $table = 'kiid_dati_tipo';
protected $primaryKey = 'lunivid';
protected $guarded = [];

public function kiidMailPdfs(): BelongsToMany
{
return $this->belongsToMany(KiidMailPdf::class, 'kiid_mail_pdf_kiid_dati_tipo', 'kiid_dati_tipo_lunivid', 'kiid_mail_pdf_lunivid');
}
}
KiidMailPdf Model:
class KiidMailPdf extends Model
{
use HasFactory;

protected $table = 'kiid_mail_pdf';
//protected $connection = 'palliauto';

public $timestamps = false;

protected $primaryKey = 'lunivid';
protected $guarded = [];

public function kiidPdfPatterns(): BelongsToMany
{
return $this->belongsToMany(KiidPdfPattern::class, 'kiid_mail_pdf_kiid_dati_tipo', 'kiid_mail_pdf_lunivid', 'kiid_dati_tipo_lunivid');
}
}
class KiidMailPdf extends Model
{
use HasFactory;

protected $table = 'kiid_mail_pdf';
//protected $connection = 'palliauto';

public $timestamps = false;

protected $primaryKey = 'lunivid';
protected $guarded = [];

public function kiidPdfPatterns(): BelongsToMany
{
return $this->belongsToMany(KiidPdfPattern::class, 'kiid_mail_pdf_kiid_dati_tipo', 'kiid_mail_pdf_lunivid', 'kiid_dati_tipo_lunivid');
}
}
...other code in the comments! Thank you all guys! 🙂
7 replies
FFilament
Created by SirAlyon on 2/6/2024 in #❓┊help
Custom Filter and Query Scope
Hi everyone, I'm facing some difficulties understanding how Filament behaves behind the scenes regarding custom filters and queries. To elaborate further: I have a resource displaying a table linked to a Laravel model. However, the table is extremely large (with several million records), and I've applied a basic scope to filter the query. MyScope: I take the latest record, read the value of a column (lunivid_serie) , and filter the entire query for the found value:
public function apply(Builder $builder, Model $model): void
{

$latestSeries = DB::table('kiid_mail_report_d')
->select('*')
->orderByDesc('tuts')
->first();


$builder->where('lunivid_serie', '=', $latestSeries->lunivid_serie);
}
public function apply(Builder $builder, Model $model): void
{

$latestSeries = DB::table('kiid_mail_report_d')
->select('*')
->orderByDesc('tuts')
->first();


$builder->where('lunivid_serie', '=', $latestSeries->lunivid_serie);
}
The issue arises when, through a custom filter, I try to provide the ability to modify this filter. I'm attempting to access the $query variable using the withoutGlobalScopes() method, but the query fails without an apparent reason (the records exist and are present; when I do dd($query), everything seems to be correctly set up). This filter is NOT working...
code in the comment...
code in the comment...
Can anyone explain to me how to have a general filter ONLY on the table and a dynamically custom filter based on the filter, so that the querydoesn't start with the same filter set to initially display the data in the table? It seems like an extremely straightforward operation, and it's surprising that there isn't a clear and precise way to achieve this result. Thanks to everyone.
8 replies
FFilament
Created by SirAlyon on 1/11/2024 in #❓┊help
Error in Filament's ImportAction Feature
Hello everyone! I'm encountering an issue with Filament's new ImportAction feature, and I've updated Filament to version 3.1 to utilize this functionality. I've generated a test importer using the automatic class generation. Everything appears to be functioning correctly until I attempt to upload a file. After the upload, I encounter the following error:
fgetcsv(): Read of 8192 bytes failed with errno=21 Is a directory.
fgetcsv(): Read of 8192 bytes failed with errno=21 Is a directory.
I'm unsure about where to begin debugging this error. Any advice or insights would be greatly appreciated. Below is the relevant code snippet: My Resource:
public static function table(Table $table): Table
{
return $table
->headerActions([
ImportAction::make()
->importer(KiidMailPdfImporter::class)
])
...other code
}
public static function table(Table $table): Table
{
return $table
->headerActions([
ImportAction::make()
->importer(KiidMailPdfImporter::class)
])
...other code
}
My Importer:
namespace App\Filament\Imports;

use App\Models\KiidMailPdf;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;

class KiidMailPdfImporter extends Importer
{
protected static ?string $model = KiidMailPdf::class;

public static function getColumns(): array
{
return [
ImportColumn::make('cstato')
->rules(['max:1']),
ImportColumn::make('tuts')
->rules(['datetime']),
ImportColumn::make('cisin')
->rules(['max:50']),

...other ImportColumn
];
}

...other generated code
namespace App\Filament\Imports;

use App\Models\KiidMailPdf;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;

class KiidMailPdfImporter extends Importer
{
protected static ?string $model = KiidMailPdf::class;

public static function getColumns(): array
{
return [
ImportColumn::make('cstato')
->rules(['max:1']),
ImportColumn::make('tuts')
->rules(['datetime']),
ImportColumn::make('cisin')
->rules(['max:50']),

...other ImportColumn
];
}

...other generated code
Thank you.. 🙂
10 replies
FFilament
Created by SirAlyon on 1/9/2024 in #❓┊help
Issue with HTTP ERROR 500 when using "->groupsOnly()" method
Hello everyone, I'm currently facing an issue and I'm struggling to understand why. Whenever I attempt to use the "->groupsOnly()" method to load closed groups in the table, it leads to a complete project breakdown with an "HTTP ERROR 500". Without utilizing this method, everything works flawlessly. Below, I've included the context in which I'm trying to implement it (following the documentation): --- Code below in the comment (too many characters) --- Any insights or assistance would be greatly appreciated! Thank you 🙂
14 replies
FFilament
Created by SirAlyon on 11/30/2023 in #❓┊help
Modal Action with Custom Livewire component
Hello everyone, I'm facing an issue with an action in a custom Livewire component. Upon clicking a button, a modal opens with a file uploader inside. Everything seems to be working correctly, but I just can't figure out why the "->action(//mycode....)" method doesn't seem to be triggered upon confirming the action. In fact, upon submitting the modal, I'm redirected back with a 'Saved' success notification. How is it possible that my dd($data) isn't being triggered? What am I missing? Livewire Controller:
class CreateOpenFundsD extends Component implements HasForms, HasActions
{
use InteractsWithActions;
use InteractsWithForms;
use WithFileUploads;

public function mount(): void
{
//....
}

public function form(Form $form): Form
{
//Only half of my form... (the other one is rendered in the livwire component view)
}

public function importHeadersAction(): Action
{
return Action::make('importHeaders')
->label('Importa Headers')
->form([
FileUpload::make('attachment')
->storeFiles(false)
->label('Carica File (CSV o XLSX)')
->acceptedFileTypes(['text/csv', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])
->columnSpan(6)
])
->action(function ($data) {
dd($data); //how this method is not triggered?
});

}
class CreateOpenFundsD extends Component implements HasForms, HasActions
{
use InteractsWithActions;
use InteractsWithForms;
use WithFileUploads;

public function mount(): void
{
//....
}

public function form(Form $form): Form
{
//Only half of my form... (the other one is rendered in the livwire component view)
}

public function importHeadersAction(): Action
{
return Action::make('importHeaders')
->label('Importa Headers')
->form([
FileUpload::make('attachment')
->storeFiles(false)
->label('Carica File (CSV o XLSX)')
->acceptedFileTypes(['text/csv', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])
->columnSpan(6)
])
->action(function ($data) {
dd($data); //how this method is not triggered?
});

}
Livewire view:
<form wire:submit="createOrUpdate">
{{ $this->form }}


<div>
{{ $this->importHeaders }}

<x-filament-actions::modals />
</div>

//other things.....
</form>
<form wire:submit="createOrUpdate">
{{ $this->form }}


<div>
{{ $this->importHeaders }}

<x-filament-actions::modals />
</div>

//other things.....
</form>
Thanks to anyone will help! Bye 🙂
31 replies
FFilament
Created by SirAlyon on 11/13/2023 in #❓┊help
Livewire custom component - Livewire Sortable
Hello everyone, actually loosing my mind trying to debug an error. I'm working with the last version of Laravel with Filament to help me customize my backend. I had to code a custom livewire component because i need to do a custom drag and drop form. I successfully handle the custom component, added the sortable livewire plugin and i tought it were working but nope! It seems like it was working because in updateAppointmentOrder() (the method that sortable triggers each time i move an item) i was dumping dd($items), but without that dd() i get an error in console and the item doesnt change position... i'll paste here my code, please help me out with this issue! 😦 Below the livewire view (as a pic because it is too much code)
5 replies
FFilament
Created by SirAlyon on 11/9/2023 in #❓┊help
Using a Livewire form inside a Filament Resource (simple)
No description
16 replies