Laravel Tricks

Browse latest tricks and tips on Laravel.

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 : 14 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 : 5 hours 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 : 23 minutes ago 12 Comments

Method spoofing in Laravel

Advantages to using route method spoofing in LaravelAs HTML forms does not supports PUT, PATCH or DELETE request. So, when defining PUT, PATCH or DELETE routes that are called from ...
published on : 17 hours ago 12 Comments

Laravel: Sanitize Request Input by using Sanitizing Middleware

How to sanitize input data in declarative manner in Laravel Laravel 5 contains a couples of middlewares. In Laravel 5.4 two new middlewares are introduced for Sanitizing inputs in ...
published on : 57 minutes ago 12 Comments

Function to get excerpt from Laravel string

How to get excerpt from string in Laravel PHPSimple PHP method/function to create excert in Laravel/** * Get excerpt from string * * @param String $str String to get an exce ...
published on : 3 hours ago 12 Comments

Non-static method should not be called statically Laravel

Non-static method illuminate\http\request::all() should not be called statically This issue was generated when we are calling a non-satic method of IlluminateHttpRequest class , T ...
published on : 1 hour ago 12 Comments

How to secure .env file in Laravel

Secure .Env File In Laravel If your are a developer and developing any app on Laravel or Symfony then you certainly is familiar with a file named as .env file which is presen ...
published on : 2 hours ago 12 Comments

Difference between –prefer-dist and –prefer-source options in composer

While installing a PHP package via composer two ways of downloading a package i.e source and dist . For stable version of packages by default composer will use dist.The source is a ...
published on : 5 hours ago 12 Comments

Create image from base64 string laravel

Simple function to Upload a Base 64 image in Laravel public function createImageFromBase64(Request $request){ $file_data = $request->input('company_logo'); ...
published on : 9 hours ago 12 Comments