Courses

Laravel Filament Admin v2: Practical Course

Repeater Field: Create Invoice with Items

avatar

I wanted invoices to be editable, so put back the 'edit' item into the getPages() function. On opening the edit form, the prices of existing invoice items are not shown. To fix that, I duplicated the afterStateUpdated method as shown in the tutorial, then changed it to afterStateHydrated.

This seems to work nicely - is it the best way to achieve this?

avatar

Good question, I never tried it. I guess your other comment about TableRepeater is the better answer.

avatar
You can use Markdown
avatar

Tip: I highly recommend the TableRepeater plugin by Martin Hwang. It accepts all the methods in the tutorial, and the resulting table is much more compact and nicer to look at than the original.

avatar
You can use Markdown
avatar

I would like a course on how to test using filament?

avatar

Well, it's all here in the documentation: https://filamentphp.com/docs/2.x/admin/testing

avatar
You can use Markdown
avatar

Laravel Filament on project with laravel-modules(nwidart/laravel-modules). The filament admin showing now found

avatar

I've never tried to combine those two packages, so hard to comment.

avatar

Thank you so much. I finaly make it work yesterday by changing the FILAMENT_PATH from ** admin** to another word. Thanks

avatar
You can use Markdown
avatar

Very very useful this part of repeaters. Anyhow, I am having trouble for an invoice with multiple items to show the total amount of the invoice in a field summing up all the items' amount. I could do that in the background afterwards, but my customer wants to see the total amount accumulated so far. Any ideas of how to show the SUM of all the ITEMS included (the field of the items is called AMOUNT)?

Thks a lot.

avatar

I found a solutions which is working!!! Inside the function afterStateUpdated(function ($state, callable $set, callable $get) {} I have first taken the array only with the items and only the column I want to be summed. Then I assign the sum of that array only column to $sumaItemsColumn variable and, finally, I set the value to the field (which is shown but disabled). $itemsColumn = array_column($get('../../items'), 'amount'); $sumaItemsColumn = array_sum($itemsColumn); $set('../../subtotal', number_format($sumaItemsColumn,2));

The key was finding how to reference items from inside items in the invoice ==> ../../items (or whatever name your repeater has).

Hope helps someone else.

avatar
Carlos Capote Pérez Andreu

Hi Albert,

Thanks for sharing. I've been trying to accomplish a similar thing where the amount is calculated from lines inserted via relation manager. In that case, the answer seems to be using Livewire events. There is an example in this StackOverflow question: https://stackoverflow.com/a/74982813

Hope its also useful to someone.

avatar
You can use Markdown
avatar

Great course. Can we use Filament in a user facing way outside of an admin panel? In your course example could you create a user facing order form?

avatar

The current v2 of filament is only for adminpanels. But upcoming v3 will do something about front facing websites, too.

avatar

My understanding was that you can install Filament Admin Panel which includes Form Builder, Table Builder and Notifications for admin, but you can also install these modules separately for user facing applications. Did I get this completely wrong? E.g. from Form builder doc:

The form builder comes pre-installed inside the admin panel 2.x, but you must still follow the installation instructions below if you're using it in the rest of your app.

avatar

This article talks about removing the separation mentioned above, in V3: https://github.com/filamentphp/filament/discussions/4400

avatar
You can use Markdown
avatar

I tried to use the replicateaction function on the table to duplicate invoice and invoice items. However I can only get the duplicate invoice but not of the invoice items. Is there a way or reading material you can recommend to acomplish this? I saw a video you did in the past using a package called cloner. I guess I can use this in the front end, but would really like using this function in the admin panel. Thanks for your help

avatar
You can use Markdown
avatar
You can use Markdown