我在 laravel 中包含一个文件,它向我抛出以下错误:
Method Illuminate\View\View::__toString() must not throw an exception
我已将文件包含在内:
@include('users.opentasks')
我在同一页面上使用两个包含,但如果我使用一个,则没有什么区别。
我不太确定这意味着什么以及如何解决这个新手问题。希望有人能帮忙。
我的代码如下:
用户控制器.php
public function profile() {
$status = "closed";
$data["projects"] = $projects = Auth::user()->projects()->where('status', '!=', $status)
->paginate(4);
//$data["tasks"] = $tasks = Auth::user()->tasks->paginate(4);
// $data["tasks_pages"] = $tasks->links();
//Comments pagination
$data["projects_pages"] = $projects->links();
if(Request::ajax())
{
$html = View::make('users.openprojects', $data)->render();
return Response::json(array('html' => $html));
// $html = View::make('users.opentasks', $data)->render();
// return Response::json(array('html' => $html));
}
echo View::make('users.profile')->with('projects', $projects);
}
public function opentasks() {
$user = User::with(array('tasks', 'tasks.status'))->find(Auth::user()->id);
return View::make('users.opentasks')->with('user', $user);
}
配置文件.blade.php
@extends("layout")
@section("content")
@include('users.openprojects')
@include('users.opentasks')
@stop
opentasks.blade.php
@foreach($user->tasks as $task)
{{ $task->task_name }}
{{ $task->task_brief}}
@if(!is_null($task->status))
{{ $task->status->status_name }}<br/><br/><br/><br/>
@endif
@endforeach