此代码适用于我的程序的某些部分,但我想知道为什么我在这个程序上出错。这是我的代码
控制器
$mydate=Carbon::now()->addHours(8);
$newdate=$mydate->toDateString();
$myquery=DB::table('attendances')
->leftJoin('employees', 'attendances.user_id', '=', 'employees.id')
->where('date_only', '=', $newdate)
->orderBy('attendances.logon','asc')->get();
return View::make('home')->with($myquery);
查看
<table >
<tr>
<td>
First Name
</td>
<td >
Last Name
</td>
<td>
Time in
</td>
</tr>
@foreach ($myquery as $mytask)
<tr>
<td >
{{$mytask->firstname}}
</td>
<td >
{{$mytask->lastname}}
</td>
<td>
{{$mytask->logon}}
</td>
</tr>
@endforeach
</table>
我已经工作了好几个小时了,但我不能解决错误,我总是得到错误500,PLease帮助
这里是$ myquery
的var_dumparray(3){[0] =&gt; object(stdClass)#156(11){[&#34; user_id&#34;] =&gt; INT(21) [&#34;登录&#34;] =&GT; string(19)&#34; 2014-11-28 08:11:12&#34; [&#34;注销&#34;] =&GT;串(19) &#34; 0000-00-00 00:00:00&#34; [&#34; date_only&#34;] =&GT; string(19)&#34; 2014-11-28 00:00:00&#34; [&#34; created_at&#34;] =&GT; string(19)&#34; 2014-11-24 07:21:06&#34; [&#34;的updated_at&#34;] =&GT; string(19)&#34; 2014-11-24 07:21:06&#34; [&#34; IN_OUT&#34;] =&GT; int(1)[&#34; id&#34;] =&gt; INT(21) [&#34;姓名&#34;] =&GT; string(4)&#34; Jake&#34; [&#34;姓&#34;] =&GT; string(5)&#34; balba&#34; [&#34;位置&#34;] =&GT; string(6)&#34; awdwad&#34; } [1] =&gt; object(stdClass)#157(11){ [&#34; USER_ID&#34;] =&GT; int(22)[&#34; logon&#34;] =&gt; string(19)&#34; 2014-11-28 08:11:17&#34; [&#34;注销&#34;] =&GT; string(19)&#34; 0000-00-00 00:00:00&#34; [&#34; date_only&#34;] =&GT; string(19)&#34; 2014-11-28 00:00:00&#34; [&#34; created_at&#34;] =&GT;串(19) &#34; 2014-11-24 08:55:04&#34; [&#34;的updated_at&#34;] =&GT; string(19)&#34; 2014-11-24 08:55:04&#34; [&#34; IN_OUT&#34;] =&GT; int(1)[&#34; id&#34;] =&gt; int(22)[&#34; firstname&#34;] =&gt; string(9)&#34; Charmaine&#34; [&#34;姓&#34;] =&GT; string(5)&#34; Balba&#34; [&#34;位置&#34;] =&GT; 字符串(10)&#34;程序员&#34; } [2] =&gt; object(stdClass)#158(11){ [&#34; USER_ID&#34;] =&GT; int(23)[&#34; logon&#34;] =&gt; string(19)&#34; 2014-11-28 08:11:27&#34; [&#34;注销&#34;] =&GT; string(19)&#34; 0000-00-00 00:00:00&#34; [&#34; date_only&#34;] =&GT; string(19)&#34; 2014-11-28 00:00:00&#34; [&#34; created_at&#34;] =&GT;串(19) &#34; 2014-11-25 07:21:31&#34; [&#34;的updated_at&#34;] =&GT; string(19)&#34; 2014-11-25 07:21:31&#34; [&#34; IN_OUT&#34;] =&GT; int(1)[&#34; id&#34;] =&gt; int(23)[&#34; firstname&#34;] =&gt; string(3)&#34; Kim&#34; [&#34;姓&#34;] =&GT;字符串(7)&#34;三星&#34; [&#34;位置&#34;] =&GT; 字符串(10)&#34;程序员&#34; }}
答案 0 :(得分:0)
我无法发表评论,但您的服务器日志又说了什么? 500错误应该在服务器错误日志中生成一行。
答案 1 :(得分:0)
您未将第二个参数传递给with
方法:
$tasks = DB::table('attendances')
->leftJoin('employees', 'attendances.user_id', '=', 'employees.id')
->where('date_only', '=', $newdate)
->orderBy('attendances.logon','asc')->get();
return View::make('home')->with('tasks', $tasks);
// then view:
@foreach ($tasks as $task)