本文整理汇总了PHP中app\Task::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::findOrFail方法的具体用法?PHP Task::findOrFail怎么用?PHP Task::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Task
的用法示例。
在下文中一共展示了Task::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
public function destroy($id)
{
$task = Task::findOrFail($id);
$task->delete();
\Session::flash('flash_message', 'Tarea borrada');
return redirect()->route('tasks.index');
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param int $id
*
* @return Response
*/
public function update($id, Request $request)
{
$task = Task::findOrFail($id);
$task->update($request->all());
Session::flash('flash_message', 'Task updated!');
return redirect('admin/task');
}
示例3: destroy
/**
* Destroy the given task.
*
* @param Request $request
* @param Task $task
* @return Response
*/
public function destroy($id, Request $request, Task $task)
{
// $this->authorize('destroy', $task);
// $task->delete();
Task::findOrFail($id)->delete();
return redirect('/tasks');
}
示例4: destroy
public function destroy($id)
{
$task = Task::findOrFail($id);
$task->delete();
Session::flash('flash_message', 'Task successfully deleted!');
return redirect()->route('tasks.index');
}
示例5: show
public function show($id)
{
$task = Task::findOrFail($id);
//dd($task);
//return $task;
return view('tasks.show', compact('task'));
}
示例6: 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);
$task->update(['title' => $request->input('title'), 'completed' => $request->input('completed')]);
return response()->json(['message' => 'Task successfully updated']);
}
示例7: destroy
public function destroy($id)
{
$task = Task::findOrFail($id);
if ($task->user_id !== Auth::user()->id) {
return response('Forbidden.')->header('Status', 403);
}
$task->delete();
}
示例8: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
$Task = Task::findOrFail($id);
if ($Task->update($request->all())) {
return "Task updated successfully.";
} else {
return $this->response->error('Task could not be created.', 404);
}
}
示例9: destroy
public function destroy($id)
{
$task = Task::findOrFail($id);
if ($task->delete()) {
return response(204);
} else {
return response(500);
}
}
示例10: doDelete
public function doDelete($id)
{
$task = Task::findOrFail($id);
try {
$task->delete();
return redirect()->back()->with('message', 'Task has been deleted successfully !');
} catch (ParseException $ex) {
echo 'Failed to delete task , with error message: ' . $ex->getMessage();
}
}
示例11: update
/**
* Updates a specific task in the database.
*
* @param int $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function update($id)
{
$this->checkPermissions($id);
// Update the task with the new data
$task = Task::findOrFail($id);
$task->update(Input::all());
// Return the updates list of tasks
$tasks = Auth::user()->tasks;
return View('tasks.list', compact('tasks'));
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(CreateCommentRequest $request, $task_id)
{
$task = Task::findOrFail($task_id);
$comment = new Comment();
$comment->fill($request->all());
$comment->task_id = $task->id;
$comment->user_id = \Auth::user()->id;
$comment->save();
$comment->user;
return $comment;
}
示例13: toggleComplete
public function toggleComplete($id)
{
try {
$task = \App\Task::findOrFail($id);
$task->is_complete = !$task->is_complete;
$task->save();
return redirect('/');
} catch (Exception $e) {
return redirect('/')->withErrors($e);
}
}
示例14: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @param TaskRequest $request
* @return Response
*/
public function update($id, TaskRequest $request)
{
$task = Task::findOrFail($id);
$task->completed = $request->input('completed');
$task->content = $request->input('content');
$task->priority = $request->input('priority');
$task->location = $request->input('location');
$task->time = $request->input('time');
$task->completed = $request->input('completed');
$task->save();
return response()->json();
}
示例15: postMain
public function postMain()
{
//neem de value van de checkbox
$task_id = Input::get("task_id");
//zoek een task met de value van de checkbox
$task = Task::findOrFail($task_id);
if ($task->user_id == Auth::user()->id) {
//als de juiste user is ingelogd verander de bool van de task
$task->isDone();
}
return Redirect::route('home');
}