Completed
Push — master ( 5a3d72...d947e8 )
by Eric
03:31
created

TaskController::indexVue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Http\Requests\DestroyTask;
6
use App\Http\Requests\ShowTask;
7
use App\Http\Requests\StoreTask;
8
use App\Http\Requests\UpdateTask;
9
use App\Task;
10
use App\User;
11
use Illuminate\Support\Facades\Redirect;
12
use Illuminate\Support\Facades\Session;
13
14
class TaskController extends Controller
15
{
16
    /**
17
     * Display a listing of the resource.
18
     *
19
     * @return \Illuminate\Http\Response
20
     */
21
    public function index()
22
    {
23
        $tasks = Task::all();
24
        $users = User::all();
25
26
        return view('tasks_php', ['tasks' => $tasks,'users' => $users]);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('tasks_php',...ks, 'users' => $users)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
27
28
    }
29
30
    /**
31
     * Show the form for creating a new resource.
32
     *
33
     * @return \Illuminate\Http\Response
34
     */
35
    public function create()
36
    {
37
        $users = User::all();
38
39
        return view('create_tasks', ['users' => $users]);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('create_task...ray('users' => $users)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
40
    }
41
42
    /**
43
     * Store a newly created resource in storage.
44
     *
45
     * @param \Illuminate\Http\Request $request
46
     *
47
     * @return \Illuminate\Http\Response
48
     */
49
    public function store(StoreTask $request)
50
    {
51
        Task::create([
52
            'name' => $request->name,
53
            'user_id' => $request->user_id,
54
            'completed' => false
55
            ]);
56
57
        Session::flash('status', 'Created ok!');
58
        return Redirect::to('/tasks_php/create');
0 ignored issues
show
Bug Best Practice introduced by
The expression return Illuminate\Suppor...to('/tasks_php/create') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
59
    }
60
61
    /**
62
     * Display the specified resource.
63
     *
64
     * @param \App\Task $task
65
     *
66
     * @return \Illuminate\Http\Response
67
     */
68
    public function show(ShowTask $request, Task $task)
69
    {
70
        return view('show_tasks', ['task' => $task]);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('show_tasks', array('task' => $task)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
71
    }
72
73
    /**
74
     * Show the form for editing the specified resource.
75
     *
76
     * @param \App\Task $task
77
     *
78
     * @return \Illuminate\Http\Response
79
     */
80
    public function edit(Task $task)
81
    {
82
        $users = User::all();
83
84
        return view('edit_tasks', ['task' => $task, 'users' => $users]);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('edit_tasks'...sk, 'users' => $users)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
85
    }
86
87
    /**
88
     * Update the specified resource in storage.
89
     *
90
     * @param \Illuminate\Http\Request $request
91
     * @param \App\Task                $task
92
     *
93
     * @return \Illuminate\Http\Response
94
     */
95
    public function update(UpdateTask $request, Task $task)
96
    {
97
        $task->update($request->only(['name','user_id']));
98
99
        Session::flash('status', 'Edited ok!');
100
        return Redirect::to('/tasks_php/edit/'.$task->id);
0 ignored issues
show
Bug Best Practice introduced by
The expression return Illuminate\Suppor...php/edit/' . $task->id) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
101
    }
102
103
    /**
104
     * Remove the specified resource from storage.
105
     *
106
     * @param \App\Task $task
107
     *
108
     * @return \Illuminate\Http\Response
109
     */
110
    public function destroy(DestroyTask $request, Task $task)
111
    {
112
        $task->delete();
113
        Session::flash('status', 'Task was deleted successful!');
114
        return Redirect::to('/tasks_php');
0 ignored issues
show
Bug Best Practice introduced by
The expression return Illuminate\Suppor...irect::to('/tasks_php') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
115
    }
116
}
117