How can i check request comes or not in laravel?
I want to get $data['student']
if request get (like: student-guardian?reg_no=0001 in URL).
if no any parameter on url $data['student']
don’t needed.
My StudentGuardian
function Like:
public function studentGuardian(Request $request)
{
$data = [];
if(!empty($request)){
$data['student'] = Student::select('id','reg_no','reg_date', 'first_name', 'middle_name', 'last_name','faculty', 'semester','status')
->where(function ($query) use ($request) {
if ($request->has('reg_no')) {
$query->where('students.reg_no', 'like', '%'.$request->reg_no.'%');
$this->filter_query['students.reg_no'] = $request->reg_no;
}
})
->get();
}
return view(('studentguardian.index'), compact('data'));
}
from Laravel Questions and Answers https://laravelquestions.com/laravel/how-can-i-check-request-comes-or-not-in-laravel/
via Lzo Media
No comments:
Post a Comment