Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php namespace App\Http\Controllers;
- use App\Http\Requests;
- use App\Project;
- use App\Task;
- use Input;
- use Redirect;
- class TasksController extends Controller {
- /**
- * Display a listing of the resource.
- *
- * @param \App\Project $project
- * @return Response
- */
- public function index(Project $project) {
- return view('tasks.index', compact('project'));
- }
- /**
- * Show the form for creating a new resource.
- *
- * @param \App\Project $project
- * @return Response
- */
- public function create(Project $project) {
- return view('tasks.create', compact('project'));
- }
- /**
- * Store a newly created resource in storage.
- *
- * @param \App\Project $project
- * @return Response
- */
- public function store(Project $project) {
- $input = Input::except('_token');
- $input['project_id'] = $project->id;
- Task::create($input);
- return Redirect::route('projects.show', $project->slug)->with('message', 'Task ' . $input['name'] . 'created.');
- }
- /**
- * Display the specified resource.
- *
- * @param \App\Project $project
- * @param \App\Task $task
- * @return Response
- */
- public function show(Project $project, Task $task) {
- return view('tasks.show', compact('project', 'task'));
- }
- /**
- * Show the form for editing the specified resource.
- *
- * @param \App\Project $project
- * @param \App\Task $task
- * @return Response
- */
- public function edit(Project $project, Task $task) {
- return view('tasks.edit', compact('project', 'task'));
- }
- /**
- * Update the specified resource in storage.
- *
- * @param \App\Project $project
- * @param \App\Task $task
- * @return Response
- */
- public function update(Project $project, Task $task) {
- // $input = array_except(Input::all(), ['_method']);
- $input = Input::all();
- $task->update($input);
- return Redirect::route('projects.tasks.show', [$project->slug, $task->slug])->with('message', 'Task updated.');
- }
- /**
- * Remove the specified resource from storage.
- *
- * @param \App\Project $project
- * @param \App\Task $task
- * @return Response
- */
- public function destroy(Project $project, Task $task) {
- try {
- $task->delete();
- return Redirect::route('projects.show', $project->slug)->with('message', 'Task deleted.');
- } catch (\Exception $e) {
- var_dump($e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement