本文整理汇总了PHP中app\Task::findorFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::findorFail方法的具体用法?PHP Task::findorFail怎么用?PHP Task::findorFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Task
的用法示例。
在下文中一共展示了Task::findorFail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view
/**
* View a specific task, and authorise it against a policy to ensure the user can view it
*
* @param Request $request
* @param $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function view(Request $request, $id)
{
$task = Task::findorFail($id);
$this->authorize('show', $task);
//Don't want to grab all tasks to then filter by though.
//Perhaps a TaskRepo function to get just the one we want.
//$task = $this->tasks->forUser($request->user());
//dd($task);
return view('board.viewtask', compact('task'));
}
示例2: show
public function show($id)
{
$task = Task::findorFail($id);
return view('tasks.show', compact('task'));
}
示例3: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$task = Task::findorFail($id);
$this->saveTask($request, $task);
}