I have for my table 'Student' 5 fields id, name, firstname, email, phone
.
My question: I would like the user to connect by putting his name what should I change?
public function index(Request $request)
{
$user = $request->user();
$students= Student::query()
->when($user->hasRole('admin') !== true, function (Builder $query) use ($user) {
$query->where('email', $user->email);
})
->when($request->has('search'), function (Builder $query) use ($request) {
$query->where('name', 'like', '%'.$request->input('search').'%');
})
->paginate(5);
return view('admin.students.index', compact('students'))
->with('display_search', $user->hasRole('admin'));
}
Here:
$query->where('email', $user->email);
I have to put this?
$query->where('name', $user->name);
Thank you for your help.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2nRYohD
via IFTTT
Aucun commentaire:
Enregistrer un commentaire