|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
|
6
|
|
|
use App\Http\Requests; |
|
7
|
|
|
use App\Sick; |
|
8
|
|
|
use App\User; |
|
9
|
|
|
|
|
10
|
|
|
class SickController extends Controller |
|
11
|
|
|
{ |
|
12
|
|
|
public function __construct() |
|
13
|
|
|
{ |
|
14
|
|
|
$this->middleware('auth'); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Display a listing of the resource. |
|
19
|
|
|
* |
|
20
|
|
|
* @return \Illuminate\Http\Response |
|
21
|
|
|
*/ |
|
22
|
|
|
public function index() |
|
23
|
|
|
{ |
|
24
|
|
|
$adata = sick::All(); |
|
25
|
|
|
return view('sick/home', ['adata' => $adata]); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Show the form for creating a new resource. |
|
30
|
|
|
* |
|
31
|
|
|
* @return \Illuminate\Http\Response |
|
32
|
|
|
*/ |
|
33
|
|
|
public function create() |
|
34
|
|
|
{ |
|
35
|
|
|
$users = User::All(); |
|
36
|
|
|
return view('sick/register', ['users' => $users]); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Store a newly created resource in storage. |
|
41
|
|
|
* |
|
42
|
|
|
* @param \Illuminate\Http\Request $request |
|
43
|
|
|
* @return \Illuminate\Http\Response |
|
44
|
|
|
*/ |
|
45
|
|
|
public function store(Request $request) |
|
46
|
|
|
{ |
|
47
|
|
|
$this->validate($request, [ |
|
48
|
|
|
'type' => 'required', |
|
49
|
|
|
'start_date' => 'required', |
|
50
|
|
|
'stop_date' => 'required', |
|
51
|
|
|
'employee' => 'required', |
|
52
|
|
|
]); |
|
53
|
|
|
|
|
54
|
|
|
$matchThese = ['user_id' => $request->get('employee'), 'start_date' => $request->get('start_date')]; |
|
55
|
|
|
$verify = sick::where($matchThese)->first(); |
|
56
|
|
|
if ($verify === null) { |
|
57
|
|
|
// user doesn't exist |
|
58
|
|
|
|
|
59
|
|
|
$data = new sick; |
|
60
|
|
|
$data->type = $request->get('type'); |
|
|
|
|
|
|
61
|
|
|
$data->start_date = $request->get('start_date'); |
|
|
|
|
|
|
62
|
|
|
$data->end_date = $request->get('stop_date'); |
|
|
|
|
|
|
63
|
|
|
$data->user_id = $request->get('employee'); |
|
|
|
|
|
|
64
|
|
|
$data->description = $request->get('description'); |
|
|
|
|
|
|
65
|
|
|
$data->save(); |
|
66
|
|
|
|
|
67
|
|
|
$user_id = $request->get('employee'); |
|
|
|
|
|
|
68
|
|
|
$subject = \Lang::get('tasks.new_sick_notification'); |
|
69
|
|
|
$mailbox = env('MAIL_USERNAME'); |
|
70
|
|
|
|
|
71
|
|
|
\Session::flash('message', "Information has been saved to the database"); |
|
72
|
|
|
\Mail::send('emails.new_sick', ['data' => $data], function ($m) use ($mailbox, $subject) { |
|
73
|
|
|
$m->from($mailbox); |
|
74
|
|
|
$m->to("[email protected]")->subject("$subject"); |
|
75
|
|
|
}); |
|
76
|
|
|
|
|
77
|
|
|
return redirect('sick'); |
|
78
|
|
|
} else { |
|
79
|
|
|
\Session::flash('error', "This data has already been saved"); |
|
80
|
|
|
return redirect('sick'); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Display the specified resource. |
|
86
|
|
|
* |
|
87
|
|
|
* @param int $id |
|
88
|
|
|
* @return \Illuminate\Http\Response |
|
89
|
|
|
*/ |
|
90
|
|
|
public function show($id) |
|
91
|
|
|
{ |
|
92
|
|
|
$data = sick::findOrFail($id); |
|
93
|
|
|
return view('sick/info', ['data' => $data, 'data_id' => $id]); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Show the form for editing the specified resource. |
|
98
|
|
|
* |
|
99
|
|
|
* @param int $id |
|
100
|
|
|
* @return \Illuminate\Http\Response |
|
101
|
|
|
*/ |
|
102
|
|
|
public function edit($id) |
|
|
|
|
|
|
103
|
|
|
{ |
|
104
|
|
|
// |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Update the specified resource in storage. |
|
109
|
|
|
* |
|
110
|
|
|
* @param \Illuminate\Http\Request $request |
|
111
|
|
|
* @param int $id |
|
112
|
|
|
* @return \Illuminate\Http\Response |
|
113
|
|
|
*/ |
|
114
|
|
|
public function update(Request $request, $id) |
|
|
|
|
|
|
115
|
|
|
{ |
|
116
|
|
|
// |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Remove the specified resource from storage. |
|
121
|
|
|
* |
|
122
|
|
|
* @param int $id |
|
123
|
|
|
* @return \Illuminate\Http\Response |
|
124
|
|
|
*/ |
|
125
|
|
|
public function destroy($id) |
|
|
|
|
|
|
126
|
|
|
{ |
|
127
|
|
|
// |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.