Skip to content
This repository has been archived by the owner on Jun 16, 2019. It is now read-only.

Commit

Permalink
Add a custom query in order to support Keira2 SAI Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoBorzi committed Jun 9, 2015
1 parent 4b5828b commit f8e81ee
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
if (
!isset($_GET['entryorguid']) &&
!isset($_GET['source_type'])
) {
) {
return Response::json(array("error" => "please insert at least one parameter"));
}

Expand Down Expand Up @@ -774,6 +774,47 @@
});


/* Custom queries for specific applications */

Route::get('/custom/GetQuestTitleByCriteria/', function() {

// See https://github.com/Discover-/SAI-Editor/blob/master/SAI-Editor/Classes/Database/WorldDatabase.cs#L344

if (
!isset($_GET['RequiredNpcOrGo1']) &&
!isset($_GET['RequiredNpcOrGo2']) &&
!isset($_GET['RequiredNpcOrGo3']) &&
!isset($_GET['RequiredNpcOrGo4']) &&
!isset($_GET['RequiredSpellCast1'])
) {
return Response::json(array("error" => "please insert at least one parameter"));
}

$query = DB::connection('world')->table('quest_template')->select('title');

if (isset($_GET['RequiredNpcOrGo1']) && $_GET['RequiredNpcOrGo1'] != "") {
$query->orWhere('RequiredNpcOrGo1', 'LIKE', '%'. $_GET['RequiredNpcOrGo1'] .'%');
}
if (isset($_GET['RequiredNpcOrGo2']) && $_GET['RequiredNpcOrGo2'] != "") {
$query->orWhere('RequiredNpcOrGo1', 'LIKE', '%'. $_GET['RequiredNpcOrGo2'] .'%');
}
if (isset($_GET['RequiredNpcOrGo3']) && $_GET['RequiredNpcOrGo3'] != "") {
$query->orWhere('RequiredNpcOrGo2', 'LIKE', '%'. $_GET['RequiredNpcOrGo3'] .'%');
$query->orWhere('RequiredNpcOrGo3', 'LIKE', '%'. $_GET['RequiredNpcOrGo3'] .'%');
}
if (isset($_GET['RequiredNpcOrGo4']) && $_GET['RequiredNpcOrGo4'] != "") {
$query->orWhere('RequiredNpcOrGo4', 'LIKE', '%'. $_GET['RequiredNpcOrGo4'] .'%');
}
if (isset($_GET['RequiredSpellCast1']) && $_GET['RequiredSpellCast1'] != "") {
$query->orWhere('RequiredSpellCast1', 'LIKE', '%'. $_GET['RequiredSpellCast1'] .'%');
}

$results = $query->get();

return Response::json($results);
});


/* Other */

Route::get('/version', function() {
Expand Down

0 comments on commit f8e81ee

Please sign in to comment.