Laravel Tricks

Browse latest tricks and tips on Laravel.

findorFail method in Laravel

How to use findOrFail() method?Sometimes you may wish to throw an exception if a specific record is not found. To do this, you may use the findOrFail method in Laravel findOrFail m ...
published on : 12 hours ago 12 Comments

Step by step guide to display wordpress posts in Laravel 5

Fetching WordPress posts in LaravelSometimes we have two different databases in our application one for Laravel and other for WordPress to manage our website blog.In this post, we ...
published on : 8 hours ago 12 Comments

Installing specific version of Laravel with Composer

How to Install specific version of Laravel.To install specific version of Laravel please run below command on your terminalcomposer create-project laravel/laravel=version-to-instal ...
published on : 8 hours ago 12 Comments

DB prefix in Lumen Framework.

How to use db prefix in Lumen? To use db prefix in Lumen, In your .env file add new constant “DB_PREFIX”Usage: DB_PREFIX=your_prefix_ ...
published on : 4 minutes ago 12 Comments

Ajax code to delete file in laravel

Deleting a file from public directory in LaravelBelow is a simple code to unlink a file in laravel.AJAX Code in your view filevar CSRF_TOKEN  =  "{{csrf_token()}}"; var ...
published on : 10 hours ago 12 Comments

Class ‘DB’ not found in Lumen

Fixing Class 'DB' not foundBy defaults Facades are not enabled in Lumen, To use DB Facade functions un-comment $app->withFacades(); line from your bootstrap/app.php file. ...
published on : 2 hours ago 12 Comments

Using Session in Laravel

Getting,Setting and Destroying session in LaravelSessions are used to store and pass information to one page to another page on website. It is a temporary storage and hold data for ...
published on : 7 hours ago 12 Comments

How to use custom table in Laravel Model?

Overriding default table name in Laravel modelYou can use custom table in Laravel by overriding protected $table property of Eloquent. Below is sample usesclass User extends Eloque ...
published on : 6 hours ago 12 Comments

What is the purpose of the Eloquent cursor() method in Laravel

Eloquent cursor() The cursor method allows you to iterate through your database records using a cursor, which will only execute a single query. When processing large amounts of d ...
published on : 57 minutes ago 12 Comments

Changing storage path permission in Laravel

Fixing Permission denied Error in LaravelSometime you got Permission denied error in Laravel. The error was caused because Laravel tries to write something to the file system and i ...
published on : 3 hours ago 12 Comments