diff options
| author | Zach DeCook <zachdecook@librem.one> | 2022-12-10 13:26:27 +0000 |
|---|---|---|
| committer | Zach DeCook <zachdecook@librem.one> | 2022-12-10 13:26:27 +0000 |
| commit | 8af58ae9f433f6d6d881e77f9128f77ea9deba19 (patch) | |
| tree | aab3361a64906ef52211018d45d376461f1d4fee /laravel/app/Song.php | |
| parent | 426f68de6edafe85a49b265aa4a86502369e25d3 (diff) | |
| download | prosongsa-8af58ae9f433f6d6d881e77f9128f77ea9deba19.tar.gz | |
searchVerse: Use the parser to validate the references
Diffstat (limited to 'laravel/app/Song.php')
| -rw-r--r-- | laravel/app/Song.php | 7 |
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:%"); } |
