Permalink
Browse files

Merge pull request #26 from dog-ears/develop

enable search by ID with condition equal
  • Loading branch information...
dog-ears committed Aug 29, 2017
2 parents d84f758 + c33b73a commit 4e09ce0b964d048f4b5115da5a38434be61b5503
@@ -45,6 +45,13 @@
<input type="hidden" name="q[s]" value="{{ @(Request::input('q')['s']) ?: '' }}" />
<div class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label" for="q_id_eq">ID</label>
<div class=" col-sm-9">
<input class="form-control input-sm" type="search" value="{{ @(Request::input('q')['id_eq']) ?: '' }}" name="q[id_eq]" id="q_id_eq" />
</div>
</div>
{{{ foreach($schemas): }}}{{{ if($this.show_in_list==true): }}}
{{{ if($this.belongsto!=): }}}
<div class="form-group">
@@ -32,6 +32,14 @@
@include('navi')
<div class="container">
@if (session('message'))
<div class="row"><div class="col-sm-12"><div class="alert alert-success alert-dismissible fade in">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
{{ session('message') }}
</div></div></div>
@endif
@yield('header')
@yield('content')
</div><!-- /.container -->
@@ -121,6 +121,20 @@ public static function getAllData( Request $request ){
$q->where($key_array[1], '<=', $value);
});
// [eq] query with related table
}elseif( strpos($key, '.') !== false && substr($key, -3) === '_eq' ){
$new_key = substr( $key, 0, strlen($key)-3 );
$key_array = explode('.', $new_key);
if( count($key_array) > 2 ){
throw new \Exception("query parameter is invalid!");
}
$myQuery = $myQuery->whereHas($key_array[0], function($q) use(&$key_array, &$value){
$q->where($key_array[1], $value);
});
// [like] query with original table
}elseif( substr($key, -5) === '_cont' ){
@@ -138,6 +152,12 @@ public static function getAllData( Request $request ){
$new_key = substr( $key, 0, strlen($key)-3 );
$myQuery = $myQuery->where($new_key, '<=', $value);
// [eq] query with original table
}elseif(substr($key, -3) === '_eq'){
$new_key = substr( $key, 0, strlen($key)-3 );
$myQuery = $myQuery->where($new_key, $value);
}
}
}

0 comments on commit 4e09ce0

Please sign in to comment.