[Live-coding] Laravel Livewire: Parent-Child Form Example

Sdílet
Vložit
  • čas přidán 24. 07. 2024
  • Livewire is great for interactivity in forms, let me show you an example with an order-products form.
    0:00 Intro: About Project
    1:04 Philosophy: Why Livewire vs jQuery/Vue
    2:52 Live-Coding Begin: Starting Point
    5:14 Installing/Enabling Livewire: "Hello"
    7:08 Livewire Component with Properties Mount
    9:40 Add Product Button: Wire-Click
    12:09 Delete Product: Method with Parameter
    13:37 Wire-Model: Binding Data
    14:53 How/When Data is Refreshed
    16:11 Final Testing and Conclusion
    Repository: github.com/LaravelDaily/Livew...
    Related links:
    - "Older" version: Master-Detail Form in Laravel + jQuery: Create Order With Products quickadminpanel.com/blog/mast...
    - Laravel Pivot Tables: Simple to Advanced Many-to-Many [VIDEO] • Laravel Pivot Tables: ...
    - - - - -
    Try our Laravel QuickAdminPanel: bit.ly/quickadminpanel
    Enroll in my Laravel courses: laraveldaily.teachable.com
  • Jak na to + styl

Komentáře • 175

  • @AbrarAhmad-mz8vl
    @AbrarAhmad-mz8vl Před 3 lety +10

    Its been since months while I'm using Livewire in all projects. It works like a charm if you understand its life cycle. Now v2 is just awesome pretty stable approach

  • @marwanfallaha3642
    @marwanfallaha3642 Před 3 lety +6

    I'm a new subscriber, I regret that I did not know this channel before. Thank you Mr. Povilas

  • @Claudio_Pereira
    @Claudio_Pereira Před 3 lety +5

    Dear Korop, I would like to congratulate you on your impressive teaching. You were able to summarize in a few minutes a subject of great complexity. Thank you for sharing!

    • @PovilasKorop
      @PovilasKorop Před 3 lety

      Thanks Claudio, that's exactly my goal!

  • @beef3379
    @beef3379 Před 3 lety

    This is so useful to me right now. Thank you! Looking forward to validation / more livewire form videos

  • @fullsetupok
    @fullsetupok Před rokem

    Hello, my name is Gaston. I am from Argentina. I want to congratulate you because your way of speaking is so clear and I can understand everything you say and learn a lot. Thank you very much.

  • @SebastianMares
    @SebastianMares Před 3 lety +1

    Just came across your channel and find it really helpful so far, so thanks and keep it up! 😊

  • @aisalen
    @aisalen Před 3 lety +1

    You are the best! Always have the desires of helping others Laravel developer.

  • @davidson7838
    @davidson7838 Před 2 lety

    Hi Povilas, Thank you very much for your invaluable teaching. this is really helpful and I was looking for something like this.

  • @MyCompsci
    @MyCompsci Před 2 lety +1

    Excellent. With livewire more laravel backend developers will easily turn out full stack!

  • @user-mw1um3yx5o
    @user-mw1um3yx5o Před 3 lety +1

    Many thanks!!! Continue to develop this topic

  • @thatsenam9183
    @thatsenam9183 Před 3 lety

    Such a awesome video. Really Enjoyed. We want more.

  • @tanzimibthesam5861
    @tanzimibthesam5861 Před 3 lety

    Simply awesome no problem of SEO lets see how it goes

  • @asifm3520
    @asifm3520 Před 3 lety

    Helpful reason for using livewire. Earlier Jquery method was quite cumbersome.

  • @trueyolu1906
    @trueyolu1906 Před 3 lety

    This video is so awesome! Thank you for your work!!!

  • @coolcha
    @coolcha Před 3 lety +5

    Very nice tutorial. Thanks. How would you pre-populate the products and quantities in the case of an edit controller form?

  • @Mb-ic4pk
    @Mb-ic4pk Před 3 lety +2

    I looove this man ♥️♥️, thank you a lot Mr.

  • @mori181186
    @mori181186 Před 3 lety

    Livewire works with Alpine.js,too. This means you will have no limits. I love livewire,too. Thanks for the video.

  • @fadyelias
    @fadyelias Před 2 lety

    Thanks very much for useful and big tutorial We need validations for this inputs

  • @juniordev4190
    @juniordev4190 Před 3 lety

    Awesome video. Thanks for sharing

  • @abdulazizredi3682
    @abdulazizredi3682 Před rokem

    Absolutely amazing video

  • @javerleo
    @javerleo Před 3 lety

    Very useful video. Thanks Povilas. I wonder if there is some guide to make record edition, since I find confusing to retrieve and save the many-to-many data.

  • @omarherri1445
    @omarherri1445 Před 3 lety +13

    Man i just was trying to implement this in one of my projects.. and boom i see your video thank you a lot

  • @techfuture-code-tv
    @techfuture-code-tv Před 3 lety

    This is magic. Very very interesting

  • @martins-ecke
    @martins-ecke Před 3 lety

    That is really cool and useful! Thank you 😃
    I wonder if data binding within a foreach loop would also works if one had checkboxes instead of a select field and multiple checkboxe can be checked. 🤔

  • @ericf3431
    @ericf3431 Před 3 lety

    Hi, this is awsome tutorial, i tried to implement it but im struggling on validation when theres a newly added input field group, using wildcard validation livewire doesnt read the the newly appended input group, how to trigger the validation if theres a new input groups added? thank you and Godbless

  • @LaravelDaily
    @LaravelDaily  Před 2 lety

    Liked this video? I have many more: subscribe to my 30+ Laravel courses, including a few courses about Livewire laraveldaily.com/courses

    • @niyo_vainqueur
      @niyo_vainqueur Před rokem +1

      can you please show us many to many relationships you used to submit that form in that database, It's kind confusing

  • @EduardR10
    @EduardR10 Před 3 lety

    :) Qué buena información. Gracias!

  • @mahmoudelsherbeny6003

    thank you, you are the best ❤

  • @martinsinansky2817
    @martinsinansky2817 Před rokem

    I am starting with livewire now on a project and I need to implement a combination of parent-child functionality with a dependent dropdowns. Normaly, when there is a single component, I would track the list of values + the selected value. However,in my case I need to have a 2-level dependent dropdowns on each child separately. So if we continue with this example, each row should also have a dropdown for product category and the product dropdown should be dependent on the category selected. The category list can be populated once in teh parent, as it is going to be the same for all children, but the product list needs to refresh for each child separately on changing the category selection.
    Anyone has any idea how to make such a combo work? I have tried nested components, but still something messes it up for me and I honestly, I am clueless on why...

  • @YoRoman
    @YoRoman Před 3 lety +1

    It's great in terms of simplicity, no need for vue/js, but it seems there'll be a lot more requests to the server.

  • @bawarabid4477
    @bawarabid4477 Před 3 lety

    Thank You. However, what if we have the price in another input "not in the options". how to implement that

  • @KasimSheyi
    @KasimSheyi Před 3 lety

    This is really nice.

  • @s.alimotamedi13
    @s.alimotamedi13 Před 2 lety

    thanks, very good course, but the problem is when we want to validate the input of list. how to do validation?

  • @patrickaoun579
    @patrickaoun579 Před 2 lety

    Thanks for this tutorial. What about adding images within this form, how do I manipulate them? Meaning, how can i access multiple images in livewire and store them in the DB?

  • @70630515
    @70630515 Před 3 lety

    thanks, very helpful.

  • @surajpaudel6215
    @surajpaudel6215 Před 2 lety

    really useful course, one problem, is how to filter products that have already been selected by the user?

  • @millionbits2023
    @millionbits2023 Před 11 měsíci

    HI, Awesome, But when I add new row then repeating data from previous child row how to prevent it ?

  • @cooltech5441
    @cooltech5441 Před 3 lety

    thanks for very usefull tutorial,
    one question? how to validate the fields?

  • @arshadsahjavi
    @arshadsahjavi Před 3 lety

    In this example, how can I make dynamically dependent dropdown.???

  • @sunkanmikitibi
    @sunkanmikitibi Před 3 lety +1

    This is a very good presentation...I was looking for this solution when this video came out very timely.. Please can you do the editting part thanks

    • @PovilasKorop
      @PovilasKorop Před 3 lety +4

      I'm planning a separate full course on Livewire

  • @MouayedElhak
    @MouayedElhak Před 3 lety

    Very nice tuto, i have a small question
    how can i add the price of the product in the same table ?

  • @amilasandaruwan9386
    @amilasandaruwan9386 Před 2 lety

    Thank you very much sir, Can you please do this video with parent-child fields validation part. It's really help

  • @brokersaddatv
    @brokersaddatv Před 3 lety

    Great video. I need a livewire example of a nested dropdown like COUNTRY and CITY. How can we do it using livewire. Should I learn livewire for Laravel projects or vuejs ?

  • @chimerakraken
    @chimerakraken Před 3 lety

    Very strong tools mixed with alpinejs and tailwindcss

  • @angelhdz6554
    @angelhdz6554 Před 2 lety

    can i use the $orderProducts variable to insert the data from the Livewire component?

  • @richardhoyle7778
    @richardhoyle7778 Před 3 lety +1

    Can you do a full courses on livewire ? Say covering the setup of a fully functioning calendar where I can setup appointments exe, as well as Projects list and client info page with address city state and zip code, contact phone exe. An avatar and job photos for the work that is to be completed before and after; that type of thing how about an API how would that be down in livewire or can it?

  • @justaman2024
    @justaman2024 Před 3 lety

    Cool, thank you!

  • @aliidhrees642
    @aliidhrees642 Před rokem

    How do I add a heading to product details form and have separate products for each heading??? Your content is already helping a lot. Thanks in advance

  • @msdeav
    @msdeav Před 3 lety +1

    Thank you. It will be very useful if you make a video creating very simple e-market with all validations, one or multiple file uploads and other stuff like that to cover all possible usages of this Livewire...

    • @msdeav
      @msdeav Před 3 lety

      And is it possible to create SPA using Livewire?

    • @PovilasKorop
      @PovilasKorop Před 3 lety +1

      I'm thinking about a separate *course* based on Livewire and some real-life project, not necessarily e-market, but something with at least a few forms and more complex stuff. Will tell the details of my plan when I have something.

    • @msdeav
      @msdeav Před 3 lety

      @@PovilasKorop Thank you

  • @ayashasiddika616
    @ayashasiddika616 Před 3 lety +2

    Sir how can update?

  • @Robawtic
    @Robawtic Před 3 lety

    How do you prevent pressing enter from creating a new child component?

  • @mohammedshopan2226
    @mohammedshopan2226 Před 2 lety

    I am new in livewire i use vue js before and i asking for design and ui in live wire can i found package do animation and ui component fast

  • @AhsanKhan89
    @AhsanKhan89 Před rokem

    @PovilasKorop I tried to follow the same process for , but the weird thing is whenever I try to press add button, It adds empty space but doesn't show the . When I perform an activity on other fields, it shows back. What could be the reason?

  • @himak21
    @himak21 Před 2 lety

    Where I can find multi validation rules of this example ?

  • @AavinSeth
    @AavinSeth Před 3 lety

    can you create an example on searching autosuggest show onfocus and hide onblur with livewire

  • @thearong_5853
    @thearong_5853 Před 2 lety

    how to add select2 to select product i have problem with this one week ago sir pls help ?:(

  • @nurharizulaimanmatharith4023

    Great videos

  • @redouaneoukaci2595
    @redouaneoukaci2595 Před 2 lety

    Hi. I use live search input instead of select html. But when i add for example 2 rows, when the searching start, the second row also do the same action. How to fix that. Thank you.

  • @JavedBaloch786
    @JavedBaloch786 Před 3 lety

    Hello Povilas,
    A question came to mind, why you didn't use AlpineJS for the increment field, isn't Alpine the best choice, Livewire each time sends an AJAX req.

  • @vidhyaprakash85
    @vidhyaprakash85 Před 3 lety

    how to show old data in the form if any request failed.

  • @imamhsn195
    @imamhsn195 Před 3 lety

    Awsome Sir. I was searching like this form interactions as you did. Just One thing different is that I am trying to add journal entries which will validate that the debit value and the credit value should be equal. I any better idea for my problem Please help me in implementing the journal entries.
    Thank you very much Again!

  • @vilandex5089
    @vilandex5089 Před 3 lety +1

    hello i keep getting post error at product.php
    Route [orders.store] not defined
    can help me fix that
    and thx love your videos

  • @socool3416
    @socool3416 Před 2 lety

    How do i update the field on livewire ?

  • @webkoth6105
    @webkoth6105 Před 3 lety

    Thanks this video.

  • @maheshmaharjan2062
    @maheshmaharjan2062 Před 3 lety

    How can we do same in select2. I have list of more than 50 items and I need the search option which only works for the 1st child. Remaining children donot have search option. Please help

  • @HRaza143
    @HRaza143 Před 2 lety

    Will it not increase the server overhead?

  • @shenelanuththara1106
    @shenelanuththara1106 Před 2 lety

    Can we save images with this same way ?

  • @MahfuzurRahmanSaber
    @MahfuzurRahmanSaber Před 3 lety

    Hi, can you give some tips about Opcache ?

  • @imadakel5844
    @imadakel5844 Před 3 lety

    i have tried inertia js but this is also more dynamic

  • @BudiYunior
    @BudiYunior Před 3 lety

    make this as series, or at least make one video about validations, it will be great, thx alot

  • @eliaszgheib6821
    @eliaszgheib6821 Před 2 lety

    please i need your help, l have installed livewire and try the example shown at livewire page (counter) but still have a main issue asking livewire.js not found, and index not found, i tried installing livewire on other pc and still having the same issue that keeps livewire not responding

  • @PanZabicom
    @PanZabicom Před 2 lety

    Whit is the name of the tutorial playlist?

  • @nelioaugusto5055
    @nelioaugusto5055 Před 3 lety

    Muito bom 👏👏

  • @erfannaseri8555
    @erfannaseri8555 Před 3 lety

    wooow tnx alot very gooooood

  • @RaicaBogdan
    @RaicaBogdan Před 2 lety

    Will this not create more load on the server since it will make requests back and fort to the backend? With a small handful of users, I don't really see a problem, but if you have hundreds, I feel that this can really create a massive issue.

  • @KasimSheyi
    @KasimSheyi Před 3 lety +1

    I must say I feel it is stressful using jquery to perform all of these after watching this video. I am definitely using livewire on my next project

  • @abhijitpal9106
    @abhijitpal9106 Před 3 lety

    Nice video sir.
    Sir how to show alert message before deleting product using livewire.

  • @rajamuruganthirumaran5310

    Hello Mr. Povilas Korop, Did you please upload a video for the same Parent-Child Form Example in the jetstream inertia.

  • @bernanddayamuntarihermawan7463

    has anyone tutorial for Livewire 2 Turbolink?

  • @proyectowebsistemasve
    @proyectowebsistemasve Před 8 měsíci

    Hello Professor, I liked your very interesting class, I am trying to unite this class with the other class of the Selects dependent on three but the part of updating the Second select when changing the First does not work, it only does it if I give it to the add more button that updates the second select
    I appreciate what you can guide me with, I am learning Laravel and Livewire

  • @vidhyaprakash85
    @vidhyaprakash85 Před 3 lety

    I need your view
    Sir, Let us consider this scenario, I have used the same one now I have developed a application has issue and return of products. Now how to manage the return of products with respect to same example. How DB can be made is such way that to record the return of products.
    Products return may be some products or all products.
    Please help me sir

  • @kristopherjafeth
    @kristopherjafeth Před rokem

    how update records?

  • @sudhirdhawle5370
    @sudhirdhawle5370 Před 3 lety

    Thank you

  • @nicolaferrara7818
    @nicolaferrara7818 Před 3 lety

    Why you have only 52ms response time? On my local environment I have about 250ms response every ajax request. What is your server configuration?

  • @oscarcontreras7848
    @oscarcontreras7848 Před 3 lety

    Great example but I think i missed a step in the installation cause the User access and the register link does not appear only the Laravel welcome page ! Do I need to run the laravel UI or any kind of Auth after I run composer install command ?

    • @PovilasKorop
      @PovilasKorop Před 3 lety +1

      For this tutorial you don't need Auth at all, but yes I used Laravel UI package to give me the design layout.

  • @bvivekvivekbas
    @bvivekvivekbas Před 3 lety

    Hi, Povilas Korop, how I make the action column stable from the scroll in livewire datatable please help me with this.

    • @LaravelDaily
      @LaravelDaily  Před 3 lety

      Sorry I don't have any quick advice about it.

  • @hertzstein
    @hertzstein Před 3 lety

    amazing, I would be great if you can mix Bootstrap Modal with LiveWire , Thank you so much for the useful example

    • @GerardoBelot
      @GerardoBelot Před 3 lety

      Just have to change mostly the css, the modal implementations is pretty easy thow!!

  • @shenelanuththara1106
    @shenelanuththara1106 Před 3 lety

    Sir, I got same problem about livewire . Could i get some-way to contact you ?

  • @allaghi
    @allaghi Před 3 lety

    Next project , I am going to use livewire

  • @borgy3263
    @borgy3263 Před 2 lety

    Got this error on Save, LOG.error: foreach() argument must be of type array|object, null given {"userId":1,"exception":{}}

    • @borgy3263
      @borgy3263 Před 2 lety

      array (
      0 =>
      array (
      'product_id' => '1',
      'quantity' => 1,
      ),
      1 =>
      array (
      'product_id' => '2',
      'quantity' => 1,
      ),
      2 =>
      array (
      'product_id' => '2',
      'quantity' => '3',
      ),
      )

  • @johnneijzen
    @johnneijzen Před 3 lety

    how is this done with edit like i want to retrieve all data back into table

    • @PovilasKorop
      @PovilasKorop Před 3 lety

      Maybe similar video on editing with Livewire would help: czcams.com/video/pfSjRcudZVA/video.html

  • @ehsanbagherzadegantalkhoun1479

    Hello sir and thank you so much for useful video I have a simple question about livewire performance I guess it shows bad performance in high traffic and big project because of many Ajax calls so in this case do you think laravel+vuejs is better or not?
    Thanks

    • @PovilasKorop
      @PovilasKorop Před 3 lety +1

      There are ways to have fewer server requests. See this video: czcams.com/video/6ggvLN_i7mk/video.html

  • @collinrobinson1294
    @collinrobinson1294 Před 3 lety

    Is there a way I can edit it after save it to the database

    • @LaravelDaily
      @LaravelDaily  Před 3 lety

      Similar video: czcams.com/video/pfSjRcudZVA/video.html

  • @adityakadam2256
    @adityakadam2256 Před 3 lety +2

    Won't it reduce the performance as server-side rendering is slower than client-side rendering?

    •  Před 3 lety

      What you mean? Blade and Nuxt are slower than Pure VueJs?

  • @yukcoding4155
    @yukcoding4155 Před 2 lety

    I implemented this in my project but I want to add Select2 plugin to select input and with JavaScrip querySelectorAll only select the first element ..what the problem

    • @LaravelDaily
      @LaravelDaily  Před 2 lety

      Select2 and Livewire don't play well together, I wouldn't recommend this

  • @nataly5440
    @nataly5440 Před 3 lety

    Thank you so much! But it doesn't work with the class "select2bs4"(( Do you know the reason?

    • @nataly5440
      @nataly5440 Před 3 lety

      Ok, for those who have the same problem)) Just add wire:ignore on html input/select tag

  • @RamuRamu-eu2sx
    @RamuRamu-eu2sx Před 7 měsíci

    How to edit function 😮

  • @marcelloperri183
    @marcelloperri183 Před 2 lety +1

    This Livewire is a revolution, we can perform a dynamic form without javascript at all, thanks for the video, very useful, it would be great if you can show how the total amount of the cart changes based on the products that you dynamically select, is it possible to do something like that?

    • @LaravelDaily
      @LaravelDaily  Před 2 lety +1

      Yes, should be possible, I've done something similar in my Livewire Kit, here's one of the components: livewirekit.com/components/checkout-price-calculator

    • @marcelloperri183
      @marcelloperri183 Před 2 lety

      Great. Thanks for the quick response

  • @gabrielavalentina7251
    @gabrielavalentina7251 Před 3 lety

    Interesante tu solución, podías usar 2 variables de livewire para lograr el mismo efecto xd $add=0; $value;

  • @ignatiusn9851
    @ignatiusn9851 Před 3 lety

    Hello Povilas, by the way what's the difference between for example $blog->author->name and $blog->author()->name. I find that each at times give different outcome (at some instance causing no results being returned)

    • @LaravelDaily
      @LaravelDaily  Před 3 lety +1

      Watch this video for the answer: czcams.com/video/MbksBczShcA/video.html