本文整理汇总了PHP中app\models\Task::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::findOrFail方法的具体用法?PHP Task::findOrFail怎么用?PHP Task::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Task
的用法示例。
在下文中一共展示了Task::findOrFail方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage via ajax.
*/
public function update(TaskRequest $request, $id)
{
if ($request->ajax()) {
$task = Task::findOrFail($id);
$task->update($request->all());
return $task;
}
return view('errors.404');
}
示例2: update
public function update($id, TaskRequest $request)
{
$task = Task::findOrFail($id);
$task->name_en = $request->input('name_en');
$task->name_bn = $request->input('name_bn');
$task->component_id = $request->input('component_id');
$task->module_id = $request->input('module_id');
$task->route = $request->input('route');
$task->icon = $request->input('icon');
$task->description = $request->input('description');
$task->ordering = $request->input('ordering');
$task->updated_by = Auth::user()->id;
$task->updated_at = time();
$task->update();
Session()->flash('flash_message', 'Task has been updated!');
return redirect('tasks');
}
示例3: find
/**
* To find tasks with given id
*
* @param $id
*
* @return task
*/
public function find($id)
{
return Task::findOrFail($id);
}
示例4: destroy
/**
* @param $id
*
* @return \Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function destroy($id)
{
try {
$task = Task::findOrFail($id);
$task->delete();
$response = ['code' => 204, 'message' => 'No Content'];
return response()->json($response, $response['code']);
} catch (ModelNotFoundException $e) {
$response = ['code' => 404, 'message' => 'Not Found'];
return response()->json($response, $response['code']);
}
}
示例5: show
public function show($taskId)
{
$taskId = intval($taskId);
$task = Task::findOrFail($taskId);
if (!$task->is_active) {
return redirect('/');
}
if ($task->taskers_only && !$this->user) {
return redirect('/auth/login');
}
ViewMapper::trackTask($task);
return view('pages.task.show', compact('task'));
}
示例6: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update(TaskRequest $request, $id)
{
$timeline['action'] = 'update';
$camp = Task::findOrFail($id);
$input = $request->all();
if ($camp->status != $input['status']) {
$timeline['description'] = '<a href="javascript:;">' . Auth::user()->first_name . ' ' . Auth::user()->last_name . '</a> changed the ' . $camp->title . ' task status to ' . $input['status'] . '.';
} else {
$timeline['description'] = '<a href="javascript:;">' . $camp->title . '</a> task has been updated by ' . Auth::user()->first_name . ' ' . Auth::user()->last_name . '.';
}
$input['updated_by'] = Auth::user()->id;
$camp->fill($input);
$camp->save();
Session::flash($this->success, Lang::get('ruban.task.updated'));
$timeline['object_type'] = 6;
$timeline['object_id'] = $id;
Timeline::create($timeline);
return Redirect::route('ruban.tasks.index');
}