Advertisement
Guest User

TasksController.php

a guest
May 21st, 2015
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.61 KB | None | 0 0
  1. <?php namespace App\Http\Controllers;
  2.  
  3. use App\Http\Requests;
  4. use App\Project;
  5. use App\Task;
  6. use Input;
  7. use Redirect;
  8.  
  9. class TasksController extends Controller {
  10.  
  11.     /**
  12.      * Display a listing of the resource.
  13.      *
  14.      * @param  \App\Project $project
  15.      * @return Response
  16.      */
  17.     public function index(Project $project) {
  18.         return view('tasks.index', compact('project'));
  19.     }
  20.  
  21.     /**
  22.      * Show the form for creating a new resource.
  23.      *
  24.      * @param  \App\Project $project
  25.      * @return Response
  26.      */
  27.     public function create(Project $project) {
  28.         return view('tasks.create', compact('project'));
  29.     }
  30.  
  31.     /**
  32.      * Store a newly created resource in storage.
  33.      *
  34.      * @param  \App\Project $project
  35.      * @return Response
  36.      */
  37.     public function store(Project $project) {
  38.         $input = Input::except('_token');
  39.         $input['project_id'] = $project->id;
  40.         Task::create($input);
  41.  
  42.         return Redirect::route('projects.show', $project->slug)->with('message', 'Task ' . $input['name'] . 'created.');
  43.     }
  44.  
  45.     /**
  46.      * Display the specified resource.
  47.      *
  48.      * @param  \App\Project $project
  49.      * @param  \App\Task $task
  50.      * @return Response
  51.      */
  52.     public function show(Project $project, Task $task) {
  53.         return view('tasks.show', compact('project', 'task'));
  54.     }
  55.  
  56.     /**
  57.      * Show the form for editing the specified resource.
  58.      *
  59.      * @param  \App\Project $project
  60.      * @param  \App\Task $task
  61.      * @return Response
  62.      */
  63.     public function edit(Project $project, Task $task) {
  64.         return view('tasks.edit', compact('project', 'task'));
  65.     }
  66.  
  67.     /**
  68.      * Update the specified resource in storage.
  69.      *
  70.      * @param  \App\Project $project
  71.      * @param  \App\Task $task
  72.      * @return Response
  73.      */
  74.     public function update(Project $project, Task $task) {
  75. //        $input = array_except(Input::all(), ['_method']);
  76.         $input = Input::all();
  77.         $task->update($input);
  78.  
  79.         return Redirect::route('projects.tasks.show', [$project->slug, $task->slug])->with('message', 'Task updated.');
  80.     }
  81.  
  82.     /**
  83.      * Remove the specified resource from storage.
  84.      *
  85.      * @param  \App\Project $project
  86.      * @param  \App\Task $task
  87.      * @return Response
  88.      */
  89.     public function destroy(Project $project, Task $task) {
  90.  
  91.         try {
  92.             $task->delete();
  93.             return Redirect::route('projects.show', $project->slug)->with('message', 'Task deleted.');
  94.         } catch (\Exception $e) {
  95.             var_dump($e);
  96.         }
  97.     }
  98.  
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement