Laravel Tricks

Browse latest tricks and tips on Laravel.

What is an Initialization function in PHP?

Initialization function is also known as constructor in PHP. The constructor is also a normal function, but it has a special feature that is always called when we initialize an obj ...
published on : 1 hour ago 12 Comments

What happens when AUTO_INCREMENT reaches the maximum value?

When AUTO_INCREMENT reaches the maximum value in MysqlIf the AUTO_INCREMENT column allows only unique values ??such as a primary key? An error occurs due to duplication (unique con ...
published on : 1 hour ago 12 Comments

Disabling error handler in laravel

How to disable error handler in Laravel framework?You can disable error and warning handler in Laravel by simply setting 'debug' => false in your config/app.php ...
published on : 5 hours ago 12 Comments

Adding Multiple Order By clause in Laravel

How to use order By clause in Laravel?Order by is used to sort sql results by column names. In this example we will see how to add multiple orderby clause in Laravel.Let take an ex ...
published on : 5 hours ago 12 Comments

Read and Write Cookie in Laravel 5

Setting and getting cookie in LaravelHi Guys, in this post we are going to see how to read and write cookies in Laravel 5.8. In Laravel all cookies are encrypted and signed with an ...
published on : 1 hour ago 12 Comments

Explain migrations in Laravel? How can you generate migration.

Laravel migrationsLaravel Migrations are like version control for your database, allowing a team to easily modify and share the application’s database schema. Migrations are typi ...
published on : 3 hours ago 12 Comments

Disabling timestamps in Laravel Eloquent

How to disable Laravel Eloquent timestamps?Simply add public $timestamps = false; in your model where you want disable timestamps.Example:namespace App; use Illuminate\Database\El ...
published on : 6 hours ago 12 Comments

IN query in Laravel Eloquent

How to use "IN" Query in Laravel ?In Laravel you can use "IN" query asUsing Eloquent$data = YourModel::whereIn('id', array(1, 2, 3))->get(); Using DB Query builder$data = DB::t ...
published on : 9 hours ago 12 Comments

Getting Random rows in Laravel Eloquent.

How to select random rows in Laravel?Sometime we have to get records from database in random order, here I am going to show some ways to get / select random records from database i ...
published on : 1 minute ago 12 Comments

How to enable maintenance mode in Laravel 5?

You can enable maintenance mode in Laravel 5, simply by executing below command.//To enable maintenance mode php artisan down //To disable maintenance mode php artisan up ...
published on : 14 minutes ago 12 Comments