/** * Display a listing of the Avator. * GET|HEAD /avators * * @return Response */ public function index(Request $request) { $offset = $request->page ? $request->page : 1; $limit = $request->limit ? $request->limit : 12; $offset = ($offset - 1) * $limit; $avators = Avator::orderBy('id', 'desc')->offset($offset)->limit($limit)->get(); return response()->json($avators); }
public function search($input) { $query = Avator::query(); $columns = Schema::getColumnListing('avators'); $attributes = array(); foreach ($columns as $attribute) { if (isset($input[$attribute]) and !empty($input[$attribute])) { $query->where($attribute, $input[$attribute]); $attributes[$attribute] = $input[$attribute]; } else { $attributes[$attribute] = null; } } return [$query->get(), $attributes]; }