tjodalv
tjodalv
FFilament
Created by tjodalv on 8/31/2024 in #❓┊help
Problem with Import Action - Import job never completes
I didn't resolve this problem. The solution for now is to remove unique constraint from that field in the database. Also if you have some foreign key constraints that fails during import the job will keep runing forever until you kill the worker and remove the job from the database.
9 replies
FFilament
Created by tjodalv on 8/31/2024 in #❓┊help
Problem with Import Action - Import job never completes
Where should I put try catch exactly? I am using standard ImportAction, I've maped columns like the docs say. The problem was that one of the field had unique constraint and my csv file have record with the value that already exists in the database. But that is not a problem really. The problem is that ImportCsv job keep executing endlessly and never completes of fails. That result millions of records in failed_import_rows table in a few minutes. So the question is why job doesn't fail when the exception is thrown?
9 replies
FFilament
Created by tjodalv on 8/31/2024 in #❓┊help
Problem with Import Action - Import job never completes
thanks for sharing your solution. I did manage to find what was causing import to fail, but still I don't know why the job didn't fail, but instead it kept running over and over again. I had the problem with UniqueConstraint exception.
9 replies
FFilament
Created by tjodalv on 8/31/2024 in #❓┊help
Problem with Import Action - Import job never completes
Can anyone help me with why the queued import job never completes?
9 replies
FFilament
Created by Abel Cobreros on 2/19/2024 in #❓┊help
Issue with halt() on beforeSave and a repeater with relationship
I am having exactly the same issue. Problem is that Filament is saving the repeater relationship before beforeSave() hook is executed.
5 replies
FFilament
Created by tjodalv on 3/13/2024 in #❓┊help
ImportAction job is failing but there is no error message
No description
8 replies
FFilament
Created by tjodalv on 3/13/2024 in #❓┊help
ImportAction job is failing but there is no error message
This is my error log from laravel.log file
8 replies
FFilament
Created by tjodalv on 2/21/2024 in #❓┊help
Action inside modal is not working
Just to post an update how I solved this problem. The problem was my misuse of Filament actions. I've created new Livewire component in which created filament table, just like the documentation says. I've passed my invoice record to the livewire via property.
// app/Livewire/InvoicePaymentsTable.php
class InvoicePaymentsTable extends Component implements HasForms, HasTable
{
use InteractsWithTable;
use InteractsWithForms;

public Invoice $invoice;

public function table(Table $table): Table
{
return $table
->relationship(fn (): MorphMany => $this->invoice->payments())
->inverseRelationship('payable')
->paginated(false)
->columns([
TextColumn::make('payed_at')->dateTime('d.m.Y'),
TextColumn::make('amount'),
])
->actions([
DeleteAction::make()
]);
}

public function render()
{
return <<<'blade'
<div>{{ $this->table }}</div>
blade;
}
}
// app/Livewire/InvoicePaymentsTable.php
class InvoicePaymentsTable extends Component implements HasForms, HasTable
{
use InteractsWithTable;
use InteractsWithForms;

public Invoice $invoice;

public function table(Table $table): Table
{
return $table
->relationship(fn (): MorphMany => $this->invoice->payments())
->inverseRelationship('payable')
->paginated(false)
->columns([
TextColumn::make('payed_at')->dateTime('d.m.Y'),
TextColumn::make('amount'),
])
->actions([
DeleteAction::make()
]);
}

public function render()
{
return <<<'blade'
<div>{{ $this->table }}</div>
blade;
}
}
And in the modal content view I called the livewire component like this:
<!-- /resources/filament/modals/payments-list.blade.php -->
...
@if ($record->payments->count() > 0)
<livewire:invoice-payments-table :invoice="$record" />
@endif
<!-- /resources/filament/modals/payments-list.blade.php -->
...
@if ($record->payments->count() > 0)
<livewire:invoice-payments-table :invoice="$record" />
@endif
And finally Action that opens that modal:
\Filament\Tables\Actions\Action::make('openPayments')
->modalContent(function (Invoice $record) {
return view('filament.modals.payments-list', compact(
'record',
));
})
\Filament\Tables\Actions\Action::make('openPayments')
->modalContent(function (Invoice $record) {
return view('filament.modals.payments-list', compact(
'record',
));
})
12 replies
FFilament
Created by tjodalv on 2/21/2024 in #❓┊help
Action inside modal is not working
Hi Saade, thank you for your help. I've refactored my code like this:
->registerModalActions([
DeleteAction::make("removeInvoicePayment")
->hiddenLabel()
->size('sm')
->icon('heroicon-s-x-mark')
])
->modalContent(function ($record, $action) {
return view('filament.modals.payments-list', compact(
'record',
'action'
));
})
->registerModalActions([
DeleteAction::make("removeInvoicePayment")
->hiddenLabel()
->size('sm')
->icon('heroicon-s-x-mark')
])
->modalContent(function ($record, $action) {
return view('filament.modals.payments-list', compact(
'record',
'action'
));
})
And in the view:
@foreach($record->payments as $payment)
<tr>
<td class="px-3 py-3.5">{{ $payment->payed_at->format('d.m.Y') }}</td>
<td class="px-3 py-3.5">{{ $payment->amount }}</td>
<td class="px-3 py-3.5">{{ $action->getModalAction('removeInvoicePayment')->name("removeInvoicePayment{$payment->id}")->record($payment) }}</td>
</tr>
@endforeach
@foreach($record->payments as $payment)
<tr>
<td class="px-3 py-3.5">{{ $payment->payed_at->format('d.m.Y') }}</td>
<td class="px-3 py-3.5">{{ $payment->amount }}</td>
<td class="px-3 py-3.5">{{ $action->getModalAction('removeInvoicePayment')->name("removeInvoicePayment{$payment->id}")->record($payment) }}</td>
</tr>
@endforeach
In the view I am renaming the button so it has unique name and assign record to be payment. There is no error, but that delete button is still not working. The record is not deleted in the database when the button is clicked.
12 replies
FFilament
Created by tjodalv on 2/21/2024 in #❓┊help
Action inside modal is not working
As I am using remove payment button inside of the for loop I created a function that constuct DeleteAction button for every row like this, but still doesn't work:
->modalContent(function ($record) {
$removePaymentAction = static function ($model) {
return DeleteAction::make("removePayment{$model->id}")
->record($model)
->hiddenLabel()
->size('sm')
->icon('heroicon-s-x-mark');
};

return view('filament.modals.payments-list', compact(
'record',
'removePaymentAction'
));
})
->modalContent(function ($record) {
$removePaymentAction = static function ($model) {
return DeleteAction::make("removePayment{$model->id}")
->record($model)
->hiddenLabel()
->size('sm')
->icon('heroicon-s-x-mark');
};

return view('filament.modals.payments-list', compact(
'record',
'removePaymentAction'
));
})
And then in view my loop goes like this:
@foreach($record->payments as $payment)
<tr>
<td class="px-3 py-3.5">{{ $payment->payed_at->format('d.m.Y') }}</td>
<td class="px-3 py-3.5">{{ $payment->amount }}</td>
<td class="px-3 py-3.5">{{ $removePaymentAction($payment) }}</td>
</tr>
@endforeach
@foreach($record->payments as $payment)
<tr>
<td class="px-3 py-3.5">{{ $payment->payed_at->format('d.m.Y') }}</td>
<td class="px-3 py-3.5">{{ $payment->amount }}</td>
<td class="px-3 py-3.5">{{ $removePaymentAction($payment) }}</td>
</tr>
@endforeach
But that still doesn't work for some reason.
12 replies
FFilament
Created by tjodalv on 2/21/2024 in #❓┊help
Action inside modal is not working
I get black modal open across the whole page with no response. Just black modal
12 replies
FFilament
Created by tjodalv on 2/21/2024 in #❓┊help
Action inside modal is not working
There is no response at all
12 replies
FFilament
Created by tjodalv on 2/21/2024 in #❓┊help
Action inside modal is not working
No description
12 replies
FFilament
Created by Askancy on 1/29/2024 in #❓┊help
Modal in form Resource
The best candidate for what you are trying to achieve would be hint action. Basically on any field you can define hint action that can open the modal with instructions:
Textarea::make('your_field_name')
->prefix('My field')
->hintAction(
Action::make('shortcode_instructions')
->modalContent(view('filament.pages.actions.shortcode-instructions'))
)
Textarea::make('your_field_name')
->prefix('My field')
->hintAction(
Action::make('shortcode_instructions')
->modalContent(view('filament.pages.actions.shortcode-instructions'))
)
More on hint actions here: https://filamentphp.com/docs/3.x/forms/actions#passing-multiple-hint-actions-to-a-field
5 replies
FFilament
Created by tjodalv on 1/27/2024 in #❓┊help
ViewAction on resource's table listing page
I've manage to find the solution to my problem using mountUsing() method on an action by inspecting how ViewAction works in the Filament. This is my solution:
Tables\Actions\Action::make('view-linked-user')
->label('Show user')
->slideOver(true)
->mountUsing(function (Form $form, Estimate $record) {
$user = User::find($record->user_id);
$form->model($user);
$form->operation('view');
$form->disabled(true);
$form->fill($user->toArray());
})
->form(function (Estimate $record): array {
return [...UserForm::fields()];
});
Tables\Actions\Action::make('view-linked-user')
->label('Show user')
->slideOver(true)
->mountUsing(function (Form $form, Estimate $record) {
$user = User::find($record->user_id);
$form->model($user);
$form->operation('view');
$form->disabled(true);
$form->fill($user->toArray());
})
->form(function (Estimate $record): array {
return [...UserForm::fields()];
});
In my form() method I am calling my custom class UserForm that define fields for this action and for my UserResource class.
9 replies
FFilament
Created by tjodalv on 1/27/2024 in #❓┊help
ViewAction on resource's table listing page
I can use table's ViewAction to open User on the ListUsers.php page. I would like to open a modal to view user details on the ListEstimate.php page. The estimate is linked to a user.
9 replies
FFilament
Created by tjodalv on 1/27/2024 in #❓┊help
ViewAction on resource's table listing page
I do not want to create separate view as I already have User resource view page. I would like to display user view in a modal from Estimate listing page. If that make sense to you.
9 replies
FFilament
Created by H.Bilbao on 1/27/2024 in #❓┊help
Reuse form componenets
You can create separate class with static method that define form fields and then call that method in multiple resources, like this:
class MyFormFields
{
public static function form(): array
{
return [
Filament\Forms\Components\TextInput::make('name'),
...
];
}
}
class MyFormFields
{
public static function form(): array
{
return [
Filament\Forms\Components\TextInput::make('name'),
...
];
}
}
And then in your resource class:
class YourResourceClass
{
public static function form(Form $form): Form
{
return $form
->schema(...MyFormFields::form());
}
}
class YourResourceClass
{
public static function form(Form $form): Form
{
return $form
->schema(...MyFormFields::form());
}
}
4 replies
FFilament
Created by tjodalv on 1/27/2024 in #❓┊help
ViewAction on resource's table listing page
Can anyone help please?
9 replies
FFilament
Created by tjodalv on 1/27/2024 in #❓┊help
ViewAction on resource's table listing page
Oh yes and I also tried to use Filament\Actions\ViewAction instead of Filament\Tables\Actions\ViewAction but that didn't work either. If I use Filament\Tables\Actions\ViewAction, when clicking on, it opens view estimate page (I want to open user linked to estimate) and if I use Filament\Actions\ViewAction then nothing happens when clicking the button.
9 replies