$query = User::where(...)->where(...);
.
.
.
$query->skip(...)->take(...);
.
.
.
$query->orderBy(...);
.
.
.
return $query->get();
You could also find useful: http://laravel.com/docs/eloquent#query-scopes
have had done this way but
$query = self::take($userdata['per_page'])->skip($userdata['start']); this become compulsory to be call first and then
static function select($userdata = array()) { $userdata['start'] = $userdata['start'] ==''? 0 : $userdata['start'];
$query = self::take($userdata['per_page'])->skip($userdata['start']);
if(isset($userdata['searchtext']) && $userdata['searchtext'] != '' && $userdata['searchtext'] != 'no')
{
$query->where('name', 'LIKE', "%".$userdata['searchtext']."%" )
-> where('email', 'LIKE', "%".$userdata['searchtext']."%" );
}
if($userdata['sorting_field'] != '' && $userdata['sorting_order'] != '')
{
$query->orderBy($userdata['sorting_field'], $userdata['sorting_order']);
}
$result = $query->get();
// return remove_html_entities($result);
return $result;
static function select($userdata = array()) { $userdata['start'] = $userdata['start'] ==''? 0 : $userdata['start'];
$query = ..........
if($userdata['per_page'] > 0 && $userdata['start'] > 0)
{
$query->take($userdata['per_page'])->skip($userdata['start']);
}
if(isset($userdata['searchtext']) && $userdata['searchtext'] != '' && $userdata['searchtext'] != 'no')
{
$query->where('name', 'LIKE', "%".$userdata['searchtext']."%" )
-> where('email', 'LIKE', "%".$userdata['searchtext']."%" );
}
if($userdata['sorting_field'] != '' && $userdata['sorting_order'] != '')
{
$query->orderBy($userdata['sorting_field'], $userdata['sorting_order']);
}
$result = $query->get();
// return remove_html_entities($result);
return $result;
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community