Skip to content

Commit

Permalink
Fix SPARQL query & not found judge
Browse files Browse the repository at this point in the history
  • Loading branch information
miyacorata committed May 1, 2021
1 parent f0c9757 commit f8b4825
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/BookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function show($bookSlug){
);
$sparqlArray = sparqlToArray($sparql);

if(count($sparqlArray) === 0) abort(404, '該当する書籍のデータが存在しません');
if(empty($sparqlArray) || empty($sparqlArray['lilyrdf:'.$bookSlug])) abort(404, '該当する書籍のデータが存在しません');

$book = array();
$lilies = array();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/LegionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function show($legionSlug){

$legion = sparqlToArray($legion_sparql);

if (empty($legion)) abort(404, "指定されたレギオンのデータは現時点で存在しません");
if (empty($legion) || empty($legion['lilyrdf:'.$legionSlug])) abort(404, "指定されたレギオンのデータは現時点で存在しません");

$icons = array();
foreach (Image::whereType('icon')->get() as $icon){
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/LilyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ public function show(string $slug)
SELECT ?subject ?predicate ?object
WHERE {
{
lilyrdf:$slug ?predicate ?object.
lilyrdf:$slug a lily:Lily;
?predicate ?object.
BIND(lilyrdf:$slug AS ?subject)
}
UNION
Expand Down Expand Up @@ -268,7 +269,7 @@ public function show(string $slug)
);
$triples = sparqlToArray($triples_sparql);

if(empty($triples)) abort(404, '該当するリリィのデータが存在しません');
if(empty($triples) || empty($triples['lilyrdf:'.$slug])) abort(404, '該当するリリィのデータが存在しません');

$triples_model = Triple::whereLilySlug($slug)->get();
foreach ($triples_model as $triple){
Expand Down

0 comments on commit f8b4825

Please sign in to comment.