In this post I will talk regarding Components also will explain how to use in Laravel.
What is Components?
In object-oriented programming and distributed object technology, a component is a reusable program building block that can be combined with other components in the same or other computers in a distributed network to form an application. Examples of a component include: a single button in a graphical user interface, a small interest calculator, an interface to a database manager.
How to use component in Laravel?
We can create a blade component in laravel 5, laravel 6, laravel 7, laravel 8 and laravel 9 using this example.
Check below image here we will make it as component, Blue Outline , One is side bar and second is Header.
For creating a components Laravel provides us a command.
$ php artisan make:component LeftSideBar
Output will be
Component created successfully.
Now you can see a new directory with a php file is created. Check below image.
Now in this blade file you can put you all LeftSideBar Code.
And The final step, to how to include in the mail blade file. For using this laravel provide us a tag
<x-LeftSideBar></x-LeftSideBar>
Like i am using in my file
Now you can check , Your styling is running smoothly. Now you can use this in any of file for left side Navigation.
Next- Passing Data To Components
Thanks for reading.
Happy Coding..
1 Comment
Thanks for your blog, nice to read. Do not stop.