/** * Display a listing of the StickerStore. * GET|HEAD /stickerStores * * @return Response */ public function index(Request $request) { $offset = $request->page ? $request->page : 1; $limit = $request->limit ? $request->limit : 12; $offset = ($offset - 1) * $limit; $posts = StickerStore::orderBy('id', 'desc')->offset($offset)->limit($limit)->get(); return response()->json($posts); }
public function search($input) { $query = StickerStore::query(); $columns = Schema::getColumnListing('stickerStores'); $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]; }