5 Tips & Tricks of Laravel
Laravel is an open-source PHP framework designed to make developing web apps easier and faster through built-in features. These features are part of what makes Laravel so widely used by web developers:
But in this blog, we are going to learn the top most tips and tricks of Laravel so that we can use this in our development and make our development easier. So lets not waste any more time and lets gets started.
Tip 1 : $loop variable in foreach
Inside of foreach loop, check if current entry is first/last by just using $loop variable.
Tip 2 : Route group within a group
in Laravel Routes, we can create a group within a group, assigning a certain middleware only to some URLs in the “parent” group.
Tip 3 : No timestamp columns
If our database table doesn’t contain timestamp fields created_at and updated_at, so we can
specify that Eloquent model wouldn’t use them, with $timestamps = false property.
Tip 4 : Don’t create Controllers for certain view
If we want route to just show a certain view, than don’t create a Controller method, just use
direct Route::view() function on web.php file.
Tip 5 : Blade @auth (user authenticated or not)
Instead of if-statement to check logged in user is authenticated or not, use @auth directive.
About Author:
Sarthi Pithadiya
Sarthi is always motivated to learn new things on development, skills, and new software. believe in creative things, new trends, and new opportunities. He has great skills in laravel, PHP, core PHP functions, and UI/UX Design Experience.