1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
6
|
|
|
use App\DoctorSpecialization; |
7
|
|
|
|
8
|
|
|
class SpecializationController extends Controller |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Display a listing of the resource. |
12
|
|
|
* |
13
|
|
|
* @return \Illuminate\Http\Response |
14
|
|
|
*/ |
15
|
|
|
public function index() |
16
|
|
|
{ |
17
|
|
|
$specialization = DoctorSpecialization::orderBy('name', 'desc')->paginate(10); |
18
|
|
|
$data = [ |
19
|
|
|
'specialization' => $specialization |
20
|
|
|
]; |
21
|
|
|
|
22
|
|
|
return view('pages.specialization')->with('data', $data); |
|
|
|
|
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Show the form for creating a new resource. |
27
|
|
|
* |
28
|
|
|
* @return \Illuminate\Http\Response |
29
|
|
|
*/ |
30
|
|
|
public function create() |
31
|
|
|
{ |
32
|
|
|
return view('pages.ext.add-specialization'); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Store a newly created resource in storage. |
37
|
|
|
* |
38
|
|
|
* @param \Illuminate\Http\Request $request |
39
|
|
|
* @return \Illuminate\Http\Response |
40
|
|
|
*/ |
41
|
|
|
public function store(Request $request) |
42
|
|
|
{ |
43
|
|
|
$this->validate($request, [ |
44
|
|
|
'degree' => 'required', |
45
|
|
|
'name' => 'required', |
46
|
|
|
'detail' => 'required|min:300' |
47
|
|
|
]); |
48
|
|
|
|
49
|
|
|
$specialty = new DoctorSpecialization; |
50
|
|
|
$specialty->degree = $request->input('degree'); |
51
|
|
|
$specialty->name = $request->input('name'); |
52
|
|
|
$specialty->detail = $request->input('detail'); |
53
|
|
|
|
54
|
|
|
if($specialty->save()) { |
55
|
|
|
return redirect (route('specialty.index'))->with('success', 'Spesialisasi telah di tambahkan'); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
return redirect (route('specialty.index'))->with('failed', 'Gagal menambah spesialisasi !'); |
|
|
|
|
59
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Display the specified resource. |
64
|
|
|
* |
65
|
|
|
* @param int $id |
66
|
|
|
* @return \Illuminate\Http\Response |
67
|
|
|
*/ |
68
|
|
|
public function show($id) |
69
|
|
|
{ |
70
|
|
|
$specialization = DoctorSpecialization::find($id); |
71
|
|
|
return view('pages.ext.view-specialization')->with('specialty', $specialization); |
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Show the form for editing the specified resource. |
76
|
|
|
* |
77
|
|
|
* @param int $id |
78
|
|
|
* @return \Illuminate\Http\Response |
79
|
|
|
*/ |
80
|
|
|
public function edit($id) |
81
|
|
|
{ |
82
|
|
|
$specialty = DoctorSpecialization::find($id); |
83
|
|
|
return view('pages.ext.edit-specialization')->with('specialty', $specialty); |
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Update the specified resource in storage. |
88
|
|
|
* |
89
|
|
|
* @param \Illuminate\Http\Request $request |
90
|
|
|
* @param int $id |
91
|
|
|
* @return \Illuminate\Http\Response |
92
|
|
|
*/ |
93
|
|
|
public function update(Request $request, $id) |
94
|
|
|
{ |
95
|
|
|
$this->validate($request, [ |
96
|
|
|
'degree' => 'required', |
97
|
|
|
'name' => 'required', |
98
|
|
|
'detail' => 'required|min:300' |
99
|
|
|
]); |
100
|
|
|
|
101
|
|
|
$specialty = DoctorSpecialization::find($id); |
102
|
|
|
$specialty->degree = $request->input('degree'); |
103
|
|
|
$specialty->name = $request->input('name'); |
104
|
|
|
$specialty->detail = $request->input('detail'); |
105
|
|
|
|
106
|
|
|
if($specialty->save()) { |
107
|
|
|
return redirect (route('specialty.index'))->with('success', 'Spesialisasi telah di update'); |
|
|
|
|
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
return redirect (route('specialty.edit', $id))->with('failed', 'Gagal memperbaharui spesialisasi !'); |
|
|
|
|
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Remove the specified resource from storage. |
115
|
|
|
* |
116
|
|
|
* @param int $id |
117
|
|
|
* @return \Illuminate\Http\Response |
118
|
|
|
*/ |
119
|
|
|
public function destroy($id) |
120
|
|
|
{ |
121
|
|
|
$specialty = DoctorSpecialization::find($id); |
122
|
|
|
if($specialty->delete()) { |
123
|
|
|
return redirect(route('specialty.index')); |
|
|
|
|
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function indexUser() |
128
|
|
|
{ |
129
|
|
|
$specialization = DoctorSpecialization::orderBy('name', 'asc')->get(); |
130
|
|
|
$data = [ |
131
|
|
|
'specialization' => $specialization |
132
|
|
|
]; |
133
|
|
|
|
134
|
|
|
return view('LSdoctor')->with('data', $data); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function indexSearch() |
138
|
|
|
{ |
139
|
|
|
$specialization = DoctorSpecialization::orderBy('created_at','desc')->orderBy('name', 'asc')->take(6)->get(); |
140
|
|
|
$data = [ |
141
|
|
|
'specialization' => $specialization |
142
|
|
|
]; |
143
|
|
|
|
144
|
|
|
return view('SearchDokter')->with('data', $data); |
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
|