@@ 48-74 (lines=27) @@ | ||
45 | * |
|
46 | * @return \Illuminate\Http\Response |
|
47 | */ |
|
48 | public function index(Request $request) |
|
49 | { |
|
50 | if (request()->has('sort')) { |
|
51 | list($sortCol, $sortDir) = explode('|', request()->sort); |
|
52 | ||
53 | $query = $this->admin_sekolah->orderBy($sortCol, $sortDir); |
|
54 | } else { |
|
55 | $query = $this->admin_sekolah->orderBy('id', 'asc'); |
|
56 | } |
|
57 | ||
58 | if ($request->exists('filter')) { |
|
59 | $query->where(function($q) use($request) { |
|
60 | $value = "%{$request->filter}%"; |
|
61 | ||
62 | $q->where('sekolah_id', 'like', $value) |
|
63 | ->orWhere('admin_sekolah_id', 'like', $value); |
|
64 | }); |
|
65 | } |
|
66 | ||
67 | $perPage = request()->has('per_page') ? (int) request()->per_page : null; |
|
68 | ||
69 | $response = $query->with(['admin_sekolah', 'sekolah', 'user'])->paginate($perPage); |
|
70 | ||
71 | return response()->json($response) |
|
72 | ->header('Access-Control-Allow-Origin', '*') |
|
73 | ->header('Access-Control-Allow-Methods', 'GET'); |
|
74 | } |
|
75 | ||
76 | /** |
|
77 | * Display a listing of the resource. |
@@ 51-77 (lines=27) @@ | ||
48 | * |
|
49 | * @return \Illuminate\Http\Response |
|
50 | */ |
|
51 | public function index(Request $request) |
|
52 | { |
|
53 | if (request()->has('sort')) { |
|
54 | list($sortCol, $sortDir) = explode('|', request()->sort); |
|
55 | ||
56 | $query = $this->prodi_sekolah->orderBy($sortCol, $sortDir); |
|
57 | } else { |
|
58 | $query = $this->prodi_sekolah->orderBy('id', 'asc'); |
|
59 | } |
|
60 | ||
61 | if ($request->exists('filter')) { |
|
62 | $query->where(function($q) use($request) { |
|
63 | $value = "%{$request->filter}%"; |
|
64 | ||
65 | $q->where('keterangan', 'like', $value) |
|
66 | ->orWhere('kuota_siswa', 'like', $value); |
|
67 | }); |
|
68 | } |
|
69 | ||
70 | $perPage = request()->has('per_page') ? (int) request()->per_page : null; |
|
71 | ||
72 | $response = $query->with(['sekolah', 'program_keahlian', 'user'])->paginate($perPage); |
|
73 | ||
74 | return response()->json($response) |
|
75 | ->header('Access-Control-Allow-Origin', '*') |
|
76 | ->header('Access-Control-Allow-Methods', 'GET'); |
|
77 | } |
|
78 | ||
79 | /** |
|
80 | * Display a listing of the resource. |