Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Make it simpler, make it better!

Andrés Herrera García andreshg112

💻
Make it simpler, make it better!
View GitHub Profile
@andreshg112
andreshg112 / OrderByField.php
Last active Jun 19, 2020
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;
/**
* Traits that eases the use of ORDER BY FIELD with an eloquent model.
* https://github.com/laravel/ideas/issues/1066
*/
trait OrderByField
{