Issues (56)

app/Http/Controllers/TaskController.php (7 issues)

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