|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace TaskManager\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use TaskManager\Http\Requests\TaskRequest; |
|
6
|
|
|
use TaskManager\Repository\TasksRepository; |
|
7
|
|
|
use TaskManager\Tasks; |
|
8
|
|
|
|
|
9
|
|
|
class TasksController extends Controller |
|
10
|
|
|
{ |
|
11
|
|
|
protected $task; |
|
12
|
|
|
function __construct( TasksRepository $task) |
|
13
|
|
|
{ |
|
14
|
|
|
$this->task = $task; |
|
15
|
|
|
$this->middleware('auth')->except('index'); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Display a listing of the resource. |
|
20
|
|
|
* @return \Illuminate\Http\Response |
|
21
|
|
|
*/ |
|
22
|
|
|
public function index() |
|
23
|
|
|
{ |
|
24
|
|
|
if (auth()->guest()) { |
|
|
|
|
|
|
25
|
|
|
return view('home'); |
|
|
|
|
|
|
26
|
|
|
} else { |
|
27
|
|
|
$archives = $this->task->allTask(); |
|
28
|
|
|
return view('tasks', compact( 'archives')); |
|
|
|
|
|
|
29
|
|
|
} |
|
30
|
|
|
} |
|
31
|
|
|
/** |
|
32
|
|
|
* Show the form for creating a new resource. |
|
33
|
|
|
* |
|
34
|
|
|
* @return \Illuminate\Http\Response |
|
35
|
|
|
*/ |
|
36
|
|
|
public function create() |
|
37
|
|
|
{ |
|
38
|
|
|
return view('create'); |
|
|
|
|
|
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Store a newly created resource in storage. |
|
43
|
|
|
* @param TaskRequest $task |
|
44
|
|
|
* @return \Illuminate\Http\Response |
|
45
|
|
|
* @internal param Request $request |
|
46
|
|
|
*/ |
|
47
|
|
|
public function store(TaskRequest $task) |
|
|
|
|
|
|
48
|
|
|
{ |
|
49
|
|
|
Tasks::create(\request(['task', 'complete','user_id'])); |
|
50
|
|
|
return redirect()->home(); |
|
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Update the specified resource in storage. |
|
55
|
|
|
* |
|
56
|
|
|
* @param Tasks $task |
|
57
|
|
|
* @return void |
|
58
|
|
|
* @internal param Request $request |
|
59
|
|
|
* @internal param Tasks $id |
|
60
|
|
|
* @internal param Tasks $tasks |
|
61
|
|
|
*/ |
|
62
|
|
|
public function update(Tasks $task) |
|
63
|
|
|
{ |
|
64
|
|
|
$this->task->mark($task); |
|
65
|
|
|
} |
|
66
|
|
|
/** |
|
67
|
|
|
* Remove the specified resource from storage. |
|
68
|
|
|
* |
|
69
|
|
|
* @param Tasks $id |
|
70
|
|
|
* @return void |
|
71
|
|
|
* @internal param Tasks $tasks |
|
72
|
|
|
*/ |
|
73
|
|
|
public function destroy(Tasks $id) |
|
74
|
|
|
{ |
|
75
|
|
|
$id->delete(); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
|
|
79
|
|
|
} |
|
80
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.