当前位置: 首页>>代码示例>>PHP>>正文


PHP Task::findOrFail方法代码示例

本文整理汇总了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');
 }
开发者ID:JuanVqz,项目名称:crud5,代码行数:7,代码来源:TasksController.php

示例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');
 }
开发者ID:thibaultvanc,项目名称:organit,代码行数:14,代码来源:TaskController.php

示例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');
 }
开发者ID:ellianadwi,项目名称:LARAVEL,代码行数:14,代码来源:TaskController.php

示例4: destroy

 public function destroy($id)
 {
     $task = Task::findOrFail($id);
     $task->delete();
     Session::flash('flash_message', 'Task successfully deleted!');
     return redirect()->route('tasks.index');
 }
开发者ID:lamfete,项目名称:crud-todoapp-laravel,代码行数:7,代码来源:TasksController.php

示例5: show

 public function show($id)
 {
     $task = Task::findOrFail($id);
     //dd($task);
     //return $task;
     return view('tasks.show', compact('task'));
 }
开发者ID:ali-sharifi,项目名称:laravel,代码行数:7,代码来源:TaskController.php

示例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']);
 }
开发者ID:LoveAndHappiness,项目名称:polymer-laravel-todoapp,代码行数:14,代码来源:TasksController.php

示例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();
 }
开发者ID:carc1n0gen,项目名称:laravel-angular-todo,代码行数:8,代码来源:TaskController.php

示例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);
     }
 }
开发者ID:sax69sax,项目名称:task-manager-api,代码行数:16,代码来源:TasksController.php

示例9: destroy

 public function destroy($id)
 {
     $task = Task::findOrFail($id);
     if ($task->delete()) {
         return response(204);
     } else {
         return response(500);
     }
 }
开发者ID:BenOvermyer,项目名称:kettle-dashboard,代码行数:9,代码来源:TasksController.php

示例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();
     }
 }
开发者ID:m-gamal,项目名称:crm,代码行数:10,代码来源:TaskController.php

示例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'));
 }
开发者ID:martyschaer,项目名称:SchoolDashboard,代码行数:16,代码来源:TaskController.php

示例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;
 }
开发者ID:BostjanOb,项目名称:ProTODO,代码行数:17,代码来源:CommentsController.php

示例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);
     }
 }
开发者ID:neon670,项目名称:php-lumen-sample,代码行数:11,代码来源:TaskController.php

示例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();
 }
开发者ID:ronal2do,项目名称:HybridApp,代码行数:19,代码来源:TaskController.php

示例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');
 }
开发者ID:gurbuzhasan,项目名称:web-backend-oplossingen,代码行数:12,代码来源:PagesController.php


注:本文中的app\Task::findOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。