找不到列:1054字段字段“电子邮件"在哪里未知 [英] Column not found: 1054 Field Field 'email' unknown in where

查看:70
本文介绍了找不到列:1054字段字段“电子邮件"在哪里未知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有3个专栏.

什么时候,我用电子邮件test.gmail.com登录到Student标题下,我可以看到我的私人信息

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

然后,我总是用电子邮件test.gmail.com登录到标题Feedback中,我收到了类似错误消息:

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返回where电子邮件= test@gmail.com)

我在表Feedbacks上的字段是:

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

我的函数index()如下:

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'));
}

谢谢您的帮助.

推荐答案

您很可能需要将email列添加到可填充数组中:

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?

这篇关于找不到列:1054字段字段“电子邮件"在哪里未知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆