當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。