Livewire Route Binding: No Need for Laravel Controller

Поделиться
HTML-код
  • Опубликовано: 5 янв 2021
  • The traditional way to use the Livewire component is to include it inside of a Blade View. But what if you can bypass all the Laravel Controller/View and add a route directly to Livewire Component? Let me show you how.
    - - - - -
    Try our Laravel QuickAdminPanel: bit.ly/quickadminpanel
    Enroll in my Laravel courses: laraveldaily.teachable.com
  • ХоббиХобби

Комментарии • 46

  • @crivion
    @crivion 3 года назад +4

    Livewire is the best thing that happened to Laravel - and thanks for your new IDE Theme! Looooooks way much better!

  • @paulfontaine7819
    @paulfontaine7819 3 года назад +2

    This is so nice and elegant. I hoped this existed, but did not know how. Thanks Povilas. Great to the point content again in just 4 minutes.

  • @ControlAltSuprimir
    @ControlAltSuprimir 3 года назад +1

    I love your channel, I don't miss any video. You are doing an amazing job!

  • @wellthatwasfun
    @wellthatwasfun 2 года назад

    Thank you! I'm new to laravel and livewire and I was struggling to understand this.. now I see it's very simple.

  • @xahiru
    @xahiru 3 года назад

    Thanks, your video is more helpful than Livewire official screencasts and docs

  • @getwebinfo4762
    @getwebinfo4762 3 года назад

    Just what I was looking for, direct and functional, thanks

  • @yuliarahma1300
    @yuliarahma1300 3 года назад

    perfect explaination exactly when I needed it, thanks

  • @tylersmith8245
    @tylersmith8245 3 года назад

    This was awesome man, thank you!

  • @alimahdavi9775
    @alimahdavi9775 3 года назад +1

    It's simple and usefull 👌👌
    Please continue making livewire short videos and make cool and pro things like filters, sorts, likebuttons, many-step forms, cache and more 👍🌹

    • @PovilasKorop
      @PovilasKorop 3 года назад

      Well, a lot of that will be covered in my upcoming livewirekit.com :) But yes, a lot is planned on the channel, too.

  • @ehsanbagherzadegantalkhoun1479
    @ehsanbagherzadegantalkhoun1479 3 года назад

    Thank you so much , do we have any way to save livewire component name in database and load it in blade template from database ?

  • @GergelyCsermely
    @GergelyCsermely 3 года назад

    Thx.

  • @TanvirAhmed-ee4zm
    @TanvirAhmed-ee4zm 3 года назад

    Hello sir, please upload an video of upload any size file by chunking in laravel.

  • @NishantKumar-tw9tu
    @NishantKumar-tw9tu 2 года назад

    How to create separate routes like laravel in livewire and how to manage large number of fields with many textarea in livewire

  • @TahirBhai
    @TahirBhai 3 года назад

    Hi, thank for this video, can you please show us how to do SPA without turbolinks in livewire. I know we can use some kind of variables by which we can do if else to show different components, but is there any better way to do it, like jumping from home page to about us page and so one without page refreshes?

    • @PovilasKorop
      @PovilasKorop 3 года назад +1

      Personally, I wouldn't create a full SPA with Livewire, that is not its purpose.

    • @TahirBhai
      @TahirBhai 3 года назад

      @@PovilasKorop Thank you sir! I got your point.

  • @dayronbornot6153
    @dayronbornot6153 3 года назад

    Hi Povilas, what if I want to make conditional the binding data in route like yours example Route::get('post/{post?}')...How handle that in the component mount() method?

    • @PovilasKorop
      @PovilasKorop 3 года назад +1

      From the official docs:
      Route::get('/post/{id}', ShowPost::class);
      class ShowPost extends Component
      {
      public $post;
      public function mount($id)
      {
      $this->post = Post::find($id);
      }
      ...
      }
      So probably conditional would work the same way, try it out, try mount($id = null) or something.
      Read more: laravel-livewire.com/docs/2.x/rendering-components#page-components

  • @user-cq1xd3vh7o
    @user-cq1xd3vh7o 2 года назад

    please help :
    when we ask no one helps and now i have a problem, so please help me
    i want to show posts of specific category when click on it :
    this is my function in button with name of category and its work well :

    {{ $post->category->name }}
    but what to do in in this function ( categoryposts )
    public function categoryposts ()
    {
    }
    and the render function too:
    public function render()
    {
    }

  • @kotakomputer4045
    @kotakomputer4045 7 месяцев назад

    How about Livewire 3?
    I have tried but the form submit refreshed.

  • @tanzimibthesam5861
    @tanzimibthesam5861 3 года назад +2

    Awesome.Livewire should be the default way of writing Laravel apps if you are not making SPA

  • @yacobee
    @yacobee 3 года назад

    and a question that: How I can show posts that their category_id is as this post
    i tried this but got error:
    public Post $post;
    $posts = Post::with('categories')->where('category_id', $this->post->categories()->id)->get();
    public function render()
    {
    $posts = Post::with('categories')->where('category_id', $this->post)->get();
    return view('livewire.post.bycategory', compact('posts'))->layout('layouts.app');
    }

  • @403gtfo
    @403gtfo 2 года назад

    2:39 love it, only thing that annoys me is intelephense throwing errors (looks like your is as well).

  • @TurkeyMaster
    @TurkeyMaster 3 года назад +1

    So i`ve been struggling for around 2 weeks on ``how to emit real time notification between users when A follow B`` .. can u make a tutorial about tihs?

    • @PovilasKorop
      @PovilasKorop 3 года назад

      Real-time notifications are about much more than just Livewire. It's like a live-chat, using something like Laravel Echo and/or Socket.io/Pusher. So read the docs for those technologies, also you may read an article from my colleague: modestasv.com/chat-with-laravel-pusher-and-socket-io-at-your-command/

  • @abdonajjar2981
    @abdonajjar2981 3 года назад +1

    could you please make example livewire with google maps
    for example in form make a marker for city or country and bind the lat and lng values to livewire componet and make update and store operation for that model

    • @PovilasKorop
      @PovilasKorop 3 года назад

      Haven't done it myself, and it would be tricky to bind Livewire back-end with JavaScript lat/lng values. But adding to the to-do list, will try.

  • @HeartHackerKhantahir
    @HeartHackerKhantahir 3 года назад +1

    What do we do if we have Route:resource() model binding?

    • @PovilasKorop
      @PovilasKorop 3 года назад +1

      You can't do it for Route::resource(), from what I know.

  • @lucifer-crybaby
    @lucifer-crybaby 3 года назад

    It's useful thank you btw can you do page loading gif with livewire ?

    • @PovilasKorop
      @PovilasKorop 3 года назад

      What do you mean by "page loading gif"? You mean showing some kind of loading indicator while loading? Then you should put somewhere: laravel-livewire.com/docs/2.x/loading-states

    • @lucifer-crybaby
      @lucifer-crybaby 3 года назад

      @@PovilasKorop yeah i mean like full screen loading overlay when i refresh the page or go to another page. i did saw that documentation i can do that in some particular element but i still don't have any idea how to do that on entire page without clicking anything sorry for my bad english

  • @fahathamm3965
    @fahathamm3965 2 года назад

    can i use livewire route with name

  • @KasimSheyi
    @KasimSheyi 3 года назад

    I usually use mine this way by grouping
    ```Route::group(['namespace' => '\App\Http\Livewire\Posts'], function () {
    Route::get('posts/{post}', Show::class);
    });```

  • @Tux0xFF
    @Tux0xFF 3 года назад

    This is default Livewire functionality, why would you create a controller then a livewire component to include in the controller?. Livewire doesnt add any overhead when using it the same way as a controller
    Caleb post on twitter says that he didnt even use one controller for over a year, just create a livewire component and that will be your "controller" with crud and everything else, no need for controllers anymore unless in very limited cases, thats how i develop my apps, and my routes file was severely reduced un number of lines when using livewire.
    In fact , using controllers and then mixing/including small livewire components is really a mess, can't imagine building a so heavily fragmented app that way, looking all over the place.

    • @PovilasKorop
      @PovilasKorop 3 года назад

      Yes, and no. Yes, if you use full-page Livewire components and your whole page is dynamic, then you're right. But my personal belief is that Livewire is great for small dynamic elements of the page, so the components should be almost like @include whenever needed.

    • @Tux0xFF
      @Tux0xFF 3 года назад

      @@PovilasKorop full page components do not cause any overhead, for very small apps they can be included, also a page doesnt need to be dynamic at all, its just about consistency throughout the application, as soon as there is more logic and features , including these components become a mess all over the place for apps like CRMs , CMSes, anything bigger than a contact form

    • @PovilasKorop
      @PovilasKorop 3 года назад

      @@Tux0xFF I would say it's a personal preference of whatever you're comfortable with. A good example is Jetstream - the app is fully Laravel, and only some form elements are with Livewire for a better UX.

  • @elkadyforsoftwares7983
    @elkadyforsoftwares7983 3 месяца назад

    Livewire is not defined

  • @entertainmentmedia8298
    @entertainmentmedia8298 3 года назад

    Does anyone knows how to make streaming music and make download restriction for all types of user using laravel? Please give me some ideas on this topic. Thanks in advance.

  •  3 года назад

    Hello, please consider buying external microphone. Since you switched to Macbook, your videos contains background sound from fans. Your videos are great, but this makes them a little less enjoyable. Thanks

    • @PovilasKorop
      @PovilasKorop 3 года назад +1

      It's so ironic, that when I switched from Macbook 2015 to the latest and greatest Macbook Pro 2020, with the idea that it will be faster to render videos and will help me to work with videos, now it's actually WORSE than the old one, and now I'm forced to spend couple hundred more for an external microphone, and also $50 on the adapter from Thunderbolt to USB. But I guess I have no choice.

  • @kennedyrayna9155
    @kennedyrayna9155 3 года назад

    Very nice 😍💋 💝💖♥️❤️