Backend for songs.zachdecook.com
Diffstat (limited to 'laravel/app/Song.php')
-rw-r--r--laravel/app/Song.php7
1 files changed, 5 insertions, 2 deletions
diff --git a/laravel/app/Song.php b/laravel/app/Song.php
index efd30a6..e2f2589 100644
--- a/laravel/app/Song.php
+++ b/laravel/app/Song.php
@@ -15,8 +15,11 @@ class Song extends Model
}
public static function whereVerse($passage)
{
- $book = explode(' ',$passage)[0];
- $chapter = (int)explode(' ', $passage)[1];
+ $parser = new BiblePassageParser();
+ // Can throw an exception.
+ $refs = $parser->parse($passage);
+ $book = (string)($refs[0]->from()->book());
+ $chapter = $refs[0]->from()->chapter();
return Song::where('verse', 'LIKE', "$book $chapter:%")->orWhere('verse',"$book $chapter")->orWhere('verse', 'LIKE', "%; $book $chapter:%");
}