~earboxer/prosongsa

5fc43b8dfcfa87b77a6ca1109636c4447fcd8c0d — Zach DeCook 10 months ago 653a6c4
Song: Make it possible to sort by verse
1 files changed, 13 insertions(+), 0 deletions(-)

M laravel/app/Song.php
M laravel/app/Song.php => laravel/app/Song.php +13 -0
@@ 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();