Posts

What is laravel livewire?

Introduction: In the realm of web development, Laravel has firmly established itself as a go-to PHP framework, known for its elegant syntax, extensive features, and thriving community. Over time, Laravel has introduced a range of tools and packages that simplify the development process. Among these, Laravel Livewire has emerged as a game-changing tool, revolutionizing Laravel development. In this blog post, we will explore the incredible capabilities of Laravel Livewire and how it can supercharge your Laravel projects. What is Laravel Livewire? Laravel Livewire is a dynamic full-stack framework that empowers developers to build interactive web interfaces using only server-side code. This innovative tool offers a simple and intuitive syntax, closely resembling Laravel Blade templates. With Livewire, you can effortlessly enhance your Laravel applications with rich user experiences, all without the need to write complex JavaScript code. Effortless Integration: One of the standout advantag

Laravel policies

Image
 Laravel policies help helps to manage the authorize user actions. Create Policy: To create run a command php artisan make:policy PostPolicy or run it will model php artisan make:policy PostPolicy --model=Post  Register Policy:  A policy can be registered in the AuthServiceProvider. So open this file and there is a default array of policies. Now add your policy with model here like:- Make Condition in Policy: Write a function which return boolean and use this function in blade or controller to mange the authorize user actions .    In above example only post author can update the post. Use policy in controller: Check user is a author of post before edit a post by authorize() in controller. Use policy in blade: To manage the accessibility of blade elements by policy use @can() method. This is the all about policy and it's use in blade & controller. to read more click here .