连接查询以合并laravel中的三个表

时间:2017-10-05 05:13:52

标签: php mysql laravel laravel-5 laravel-5.3

我希望基于department_string_id将项目表与department表连接,并将项目表中的project_owner_id与用户表连接,条件project的项目表为aceid.project_owner_id = users.aceid

desired query (working fine)
 select p.*,d.department_head_aceid from project as p inner join department as d on p.department_string_id=d.department_string_id inner join users as u on p.project_owner_id=u.aceid where u.id='4' 

Laravel查询

 $approver_id_roles=DB::table('project')
         ->join('department', 'project.department_string_id', '=', 'department.department_string_id')->join('users','project.project_owner_id','=','users.aceid')
         ->where('project.project_owner_id','=','users.aceid')
         ->select('department.department_head_aceid')->get();

发现以下错误

  

VerifyCsrfToken.php第68行中的TokenMismatchException:

我在这里做错了什么

1 个答案:

答案 0 :(得分:1)

为避免CSRF攻击,我们希望在表单中添加令牌。 Laravel token

<input type="hidden" name="_token" value="{{ csrf_token() }}">