Column not found: 1054 Field Field 'email'

2019-08-28 01:05发布

I have 3 rubrics for now.

enter image description here

When, I login in the rubric Studentwith the email test.gmail.com I can see my informations private

enter image description here

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 fromreturnswhere 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.

1条回答
Juvenile、少年°
2楼-- · 2019-08-28 02:00

You most likely need to add the email column to your fillable array:

protected $fillable = ['user_id','instruction', 'description', 'fk_eleve', 'email'];

Did you further create a proper migration for this, like does the table have the column email?

查看更多
登录 后发表回答