From 8af58ae9f433f6d6d881e77f9128f77ea9deba19 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Sat, 10 Dec 2022 13:26:27 +0000 Subject: searchVerse: Use the parser to validate the references --- laravel/app/Song.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'laravel/app/Song.php') 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:%"); } -- cgit 1.4.1