I have 3 rubrics for now.
When, I login in the rubric Student
with the email test.gmail.com
I can see my informations private
Then, I LOGIN in the rubric Feedback
always with the email test.gmail.com
I have like error message:
SQLSTATE [42S22]: Column not found: 1054 Field Field 'email' unknown in where (SQL: select count (*) as aggregate from
returnswhere
email= test@gmail.com)
my fields on the table Feedbacks
are:
protected $fillable = ['user_id','instruction', 'description', 'fk_eleve'];
My function index() is the following:
public function index(Request $request)
{
$user = $request->user();
$feedbacks = Feedback::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->join('eleves', 'feedbacks.fk_eleve', '=', 'eleves.id')->orderBy('eleves.nom', 'asc')->where('eleves.nom','like','%'.$request->input('search').'%');
})
->paginate(5);
return view('admin.feedbacks.index', compact('feedbacks'))
->with('display_search', $user->hasRole('admin'));
}
Thank you for your help.