Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function search(Request $request)
- {
- $validator = \Validator::make($request->all(), [
- 'state' => 'required',
- 'lga' => 'required',
- 'blood_type' => 'required',
- 'pints' => 'required',
- ]);
- if($validator->fails())
- {
- return $this->errorUnauthorized('Ensure you fill all field don\'t leave any empty');
- }
- $query = $request->all();
- if ($query) //$query is an array, you might want to do if(count($query) > 0);
- {
- // $blood_bank = Search::where('state_id', 'LIKE', '%' . $query . '%')
- //->orWhere('lga_id', 'LIKE', '%' . $query . '%')
- //->get();
- /* Using and might be better here if you want exact matches of all four search criteria */
- $state = DB::table('state')->where()
- $blood_bank = ::where('state_id', $query['state'])
- ->where('lga_id', $query['lga'])
- ->where('blood_type', 'like', '%'. $query['blood_type]')
- ->where(pints, '>=', $query['pints'])->get();
- return response()->json(compact('blood_bank'));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement