Recent Posts

Laravel Multiple Database Connections

Hi devs, in this quick tip, i’ll show you how to add multiple database connections to your laravel project. let’s see how we can do this. First, add second database connection variable in .env file. Next, define database connection in config/database.php file.   Now, we are done with configuration. We ...

Dynamically Add Middleware in Laravel

Hi guys, we all know how to to add middlewares in the kernel, but what if we want to add middleware only under certain conditions. So, in this quick tip, i’ll show you how to add dynamic middleware in laravel. In this example, i want to activate middleware ...

Validate Custom Date Format with Laravel Validator

Hi artisan, I’m going to share with you how to validate a custom date format in Laravel. In this example, you will see the use date validation rules that is provided by Laravel Let’s dive in: date date_format after:date after_or_equal:date before:date before_or_equal:date 1- Date Validation 2- Date Validation ...

How to check request is ajax or not in Laravel

hi guys, I will let you know how to detect if request is ajax or not in Laravel. Sometime you need to check if request is ajax then response data only and if request is not ajax then response complete view in your application. By using ajax() method in Laravel, ...

How To Log All SQL Queries In Laravel

Hi guys, in this tutorial tips we will learn how to log all SQL Queries. There are multiple ways to create SQL Query Log and we will see three of them :   1- Default Log file Log in the default log file “laravel.log” located at “storage/logs”. To log SQL ...

Create Custom Maintenance Page in Laravel

Hi guys, , in this tutorial, we are going to create our custom maintenance page in Laravel. I’m testing on Laravel 7.x. Let’s get started: To put website into maintenance mode, we have to run this command: To make application up and running again, run this command: Laravel displays 503 page ...

30 Laravel Eloquent Tips & Tricks

Hi, today I’m going to share with you some tips and tricks in Laravel Eloquent ORM. There are a lot of semi-hidden functions and less-known ways to achieve more with it. Let’s dive in:   1- The Exists Property The exists property is used to show whether the ...

Laravel Timestamps tricks

Hi guys, today I’m going to share with you some timestamp tricks in Laravel. Let’s dive in: 1- Disable Timestamps If your DB table doesn’t contain timestamp fields created_at and updated_at, you can specify that Eloquent model wouldn’t use them, with $timestamps = false property.   2- Change Timestamp Column ...