Skip to content

Instantly share code, notes, and snippets.

💻
Make it simpler, make it better!

Andrés Herrera García andreshg112

💻
Make it simpler, make it better!
Block or report user

Report or block andreshg112

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@andreshg112
andreshg112 / OrderByField.php
Last active Oct 16, 2019
It can be used for queries like this in MySQL: `SELECT * FROM `plans` ORDER BY FIELD(`interval`, 'day', 'week', 'month', 'year');`
View OrderByField.php
<?php
namespace App\Traits;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\DB;
/**
* Traits that eases the use of ORDER BY FIELD with an eloquent model.
You can’t perform that action at this time.