about summary refs log tree commit diff
path: root/laravel/app
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2022-12-10 13:26:27 +0000
committerZach DeCook <zachdecook@librem.one>2022-12-10 13:26:27 +0000
commit8af58ae9f433f6d6d881e77f9128f77ea9deba19 (patch)
treeaab3361a64906ef52211018d45d376461f1d4fee /laravel/app
parent426f68de6edafe85a49b265aa4a86502369e25d3 (diff)
downloadprosongsa-8af58ae9f433f6d6d881e77f9128f77ea9deba19.tar.gz
searchVerse: Use the parser to validate the references
Diffstat (limited to 'laravel/app')
-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:%");
     }