Skip to main content

Repeater Field: Create Invoice with Items

Premium
8:28

The Full Lesson is Only for Premium Members

Want to access all of our courses? (31 h 16 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

MH
Michael HASSE ✓ Link copied!

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?

PK
Povilas Korop ✓ Link copied!

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

MH
Michael HASSE ✓ Link copied!

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.

MG
Mario Garcia ✓ Link copied!

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

PK
Povilas Korop ✓ Link copied!

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

SA
Showemimo Adebare ✓ Link copied!

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

PK
Povilas Korop ✓ Link copied!

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

SA
Showemimo Adebare ✓ Link copied!

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

A
AlbertLens ✓ Link copied!

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.

A
AlbertLens ✓ Link copied!

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.

CC
Carlos Capote Pérez Andreu ✓ Link copied!

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.

E
Emaz ✓ Link copied!

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?

PK
Povilas Korop ✓ Link copied!

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

MH
Michael HASSE ✓ Link copied!

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.

MH
Michael HASSE ✓ Link copied!

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

R
RobertT ✓ Link copied!

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