diff options
| author | Zach DeCook <zachdecook@librem.one> | 2023-07-20 02:06:43 +0000 |
|---|---|---|
| committer | Zach DeCook <zachdecook@librem.one> | 2023-07-20 02:06:43 +0000 |
| commit | 5fc43b8dfcfa87b77a6ca1109636c4447fcd8c0d (patch) | |
| tree | a567860bf5d4b9ac7482a96b74902db3e6f5accd /laravel | |
| parent | 653a6c4db19efbbd72c39e7723b06d6ce8291f1a (diff) | |
| download | prosongsa-5fc43b8dfcfa87b77a6ca1109636c4447fcd8c0d.tar.gz | |
Song: Make it possible to sort by verse
Diffstat (limited to 'laravel')
| -rw-r--r-- | laravel/app/Song.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/laravel/app/Song.php b/laravel/app/Song.php index c4722a2..b8d2e4c 100644 --- a/laravel/app/Song.php +++ b/laravel/app/Song.php @@ -21,6 +21,19 @@ class Song extends Model $bc = explode(':', $refs[0])[0]; return Song::where('verse', 'LIKE', "$bc:%")->orWhere('verse',"$bc")->orWhere('verse','like',$refs[0].";%")->orWhere('verse', 'LIKE', "%; $bc:%"); } + public function getPassagesAttribute() { + $parser = new BiblePassageParser(); + $refs = $parser->parse($this->verse); + return $refs; + } + public static function passageSort($a, $b) { + try { + return $a->passages[0]->from()->integerNotation() <=> $b->passages[0]->from()->integerNotation(); + } catch (\Exception $e) { + // I don't care. + } + return 0; + } public function textTranspose($key) { $sc = new SongController(); |
