1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
6
|
|
|
use App\Http\Requests; |
7
|
|
|
use App\Departments; |
8
|
|
|
use App\Department_members; |
9
|
|
|
use Mail; |
10
|
|
|
use App\User; |
11
|
|
|
|
12
|
|
|
class DepartmentsController extends Controller |
13
|
|
|
{ |
14
|
|
|
public function __construct() |
15
|
|
|
{ |
16
|
|
|
$this->middleware('auth'); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public function index() |
20
|
|
|
{ |
21
|
|
|
$departments = Departments::orderBy('department_name', 'asc')->paginate(10); |
22
|
|
|
return view('departments/list', ['departments' => $departments]); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function create() |
26
|
|
|
{ |
27
|
|
|
$managers = User::all(); |
28
|
|
|
return view('departments/create', ['managers' => $managers]); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Store a newly created resource in storage. |
33
|
|
|
* |
34
|
|
|
* @param \Illuminate\Http\Request $request |
35
|
|
|
* @return \Illuminate\Http\Response |
36
|
|
|
*/ |
37
|
|
|
public function store(Request $request) |
38
|
|
|
{ |
39
|
|
|
$departments = new Departments; |
40
|
|
|
$departments->department_name = $request->get('department_name'); |
|
|
|
|
41
|
|
|
$departments->department_manager = $request->get('department_manager'); |
|
|
|
|
42
|
|
|
$departments->department_description = $request->get('department_description'); |
|
|
|
|
43
|
|
|
$departments->save(); |
44
|
|
|
|
45
|
|
|
$department_id = $departments->id; |
|
|
|
|
46
|
|
|
|
47
|
|
|
$manager = new Department_members; |
48
|
|
|
$manager->departmentid = $department_id; |
|
|
|
|
49
|
|
|
$manager->userid = $request->get('department_manager'); |
|
|
|
|
50
|
|
|
$manager->save(); |
51
|
|
|
|
52
|
|
|
\Session::flash('message', "New department has been saved"); |
53
|
|
|
return redirect('staff/departments'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Display the specified resource. |
58
|
|
|
* |
59
|
|
|
* @param int $id |
60
|
|
|
* @return \Illuminate\Http\Response |
61
|
|
|
*/ |
62
|
|
|
public function show($id) |
|
|
|
|
63
|
|
|
{ |
64
|
|
|
// |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Show the form for editing the specified resource. |
69
|
|
|
* |
70
|
|
|
* @param int $id |
71
|
|
|
* @return \Illuminate\Http\Response |
72
|
|
|
*/ |
73
|
|
|
public function edit($id) |
|
|
|
|
74
|
|
|
{ |
75
|
|
|
// |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Update the specified resource in storage. |
80
|
|
|
* |
81
|
|
|
* @param \Illuminate\Http\Request $request |
82
|
|
|
* @param int $id |
83
|
|
|
* @return \Illuminate\Http\Response |
84
|
|
|
*/ |
85
|
|
|
public function update(Request $request, $id) |
|
|
|
|
86
|
|
|
{ |
87
|
|
|
// |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Remove the specified resource from storage. |
92
|
|
|
* |
93
|
|
|
* @param int $id |
94
|
|
|
* @return \Illuminate\Http\Response |
95
|
|
|
*/ |
96
|
|
|
public function destroy($id) |
|
|
|
|
97
|
|
|
{ |
98
|
|
|
// |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
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@property
annotation 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.