Laravel Tricks

Browse latest tricks and tips on Laravel.

PHP artisan optimize command

php artisan optimize is used to remove the boostrap/cache/ directory files and recreates it.From Laravel 5.5 php artisan optimize commnad is removed and no longer needed. ...
published on : 3 hours ago 12 Comments

clear-compiled Command in Laravel

Laravel's clear-compiled is an artisan command to clear the compiled classes and services.To clear compiled classes in Laravel please run below command. php artisan clear-comp ...
published on : 3 hours ago 12 Comments

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 : 3 hours 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 : 2 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 : 31 minutes 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 : 3 hours 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 : 1 hour 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 : 3 hours ago 12 Comments