Backend for songs.zachdecook.com
Diffstat (limited to 'laravel/app/Song.php')
| -rw-r--r-- | laravel/app/Song.php | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/laravel/app/Song.php b/laravel/app/Song.php index b8d2e4c..ed2bf25 100644 --- a/laravel/app/Song.php +++ b/laravel/app/Song.php @@ -3,6 +3,7 @@ namespace App; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\DB; use App\Http\Controllers\SongController; use TechWilk\BibleVerseParser\BiblePassageParser; @@ -13,6 +14,11 @@ class Song extends Model { return $this->belongsToMany('App\Playlist'); } + public function scopeInRandomOrderSeeded($query, $id = 0) { + $seed = ((intval(now()->unix()/600) . $id)%100000)/100000; + DB::query()->selectRaw("SETSEED($seed)")->get(); + $query->inRandomOrder(); + } public static function whereVerse($passage) { $parser = new BiblePassageParser(); |