WHAT I LIKE MOST ABOUT LARAVEL (LIVEWIRE) wire:click

Video thumbnail

I want to tell you what I like most about Laravel in general, although, I point out Livewire but for me, even though it is the best thing about Laravel, it is simply this:

wire:click="selectCategodyToDelete({{ $c }})"

For me, there's nothing that surpasses this. Why do I mean this? I also mentioned this a bit in another video, but what are we doing here? What does the previous code mean? Remember, it would be a client-side file. I know it's PHP, but remember that the final rendering is going to be a view. That's transparent to us. That's the final rendering when consumed from the page. In this case, it's a list. It's going to be something like what we have here, just like a pure HTML list. HTML, JavaScript, and CSS. That's what the browser understands. But

What are we doing here? I find it so fascinating. Basically, remember that this is a method we have on the server:

function selectCategodyToDelete(Category $category){
    $this->categoryToDelete = $category;
}

That is, directly, and that's the word here: directly, we're calling a server method.

In other frameworks, or without Livewire, we have to create the route, controller, and a request using Axios or Fetch to simulate the integration we have with Livewire:

wire:click="selectCategodyToDelete({{ $c }})"

Livewire events the key

Of course, with wire click I mean events in general, like submit, it's the same but what changes is the event. I mention the click event since it's the most generic and used, but there are others like submit, change... that you can look up in the official documentation.

I'll tell you about the feature I like most about Laravel (Livewire) and the one I use the most in my daily life.

I agree to receive announcements of interest about this Blog.

Andrés Cruz

ES En español