@@ -6,8 +6,7 @@ |
||
6 | 6 | use App\City; |
7 | 7 | use App\DoctorSpecialization; |
8 | 8 | |
9 | -class SpecializationController extends Controller |
|
10 | -{ |
|
9 | +class SpecializationController extends Controller { |
|
11 | 10 | /** |
12 | 11 | * Display a listing of the resource. |
13 | 12 | * |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | $specialty->name = $request->input('name'); |
53 | 53 | $specialty->detail = $request->input('detail'); |
54 | 54 | |
55 | - if($specialty->save()) { |
|
56 | - return redirect (route('specialty.index'))->with('success', 'Spesialisasi telah di tambahkan'); |
|
55 | + if ($specialty->save()) { |
|
56 | + return redirect(route('specialty.index'))->with('success', 'Spesialisasi telah di tambahkan'); |
|
57 | 57 | } |
58 | 58 | |
59 | - return redirect (route('specialty.index'))->with('failed', 'Gagal menambah spesialisasi !'); |
|
59 | + return redirect(route('specialty.index'))->with('failed', 'Gagal menambah spesialisasi !'); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | $specialty->name = $request->input('name'); |
105 | 105 | $specialty->detail = $request->input('detail'); |
106 | 106 | |
107 | - if($specialty->save()) { |
|
108 | - return redirect (route('specialty.index'))->with('success', 'Spesialisasi telah di update'); |
|
107 | + if ($specialty->save()) { |
|
108 | + return redirect(route('specialty.index'))->with('success', 'Spesialisasi telah di update'); |
|
109 | 109 | } |
110 | 110 | |
111 | - return redirect (route('specialty.edit', $id))->with('failed', 'Gagal memperbaharui spesialisasi !'); |
|
111 | + return redirect(route('specialty.edit', $id))->with('failed', 'Gagal memperbaharui spesialisasi !'); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | public function destroy($id) |
121 | 121 | { |
122 | 122 | $specialty = DoctorSpecialization::find($id); |
123 | - if($specialty->delete()) { |
|
123 | + if ($specialty->delete()) { |
|
124 | 124 | return redirect(route('specialty.index')); |
125 | 125 | } |
126 | 126 | } |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | |
138 | 138 | public function indexSearch() |
139 | 139 | { |
140 | - $specialization = DoctorSpecialization::orderBy('created_at','desc')->orderBy('name', 'asc')->take(6)->get(); |
|
141 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
140 | + $specialization = DoctorSpecialization::orderBy('created_at', 'desc')->orderBy('name', 'asc')->take(6)->get(); |
|
141 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
142 | 142 | $data = [ |
143 | 143 | 'specialization' => $specialization, |
144 | 144 | 'location' => $location |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | |
150 | 150 | public function searchSpecialty(Request $request) |
151 | 151 | { |
152 | - $specialization = DoctorSpecialization::where('name','LIKE','%'.$request->specialty.'%')->orderBy('name','asc')->get(); |
|
152 | + $specialization = DoctorSpecialization::where('name', 'LIKE', '%'.$request->specialty.'%')->orderBy('name', 'asc')->get(); |
|
153 | 153 | $data = [ |
154 | 154 | 'specialization' => $specialization |
155 | 155 | ]; |
156 | 156 | |
157 | - return view('LSdoctor')->with('data',$data); |
|
157 | + return view('LSdoctor')->with('data', $data); |
|
158 | 158 | } |
159 | 159 | } |
@@ -138,9 +138,9 @@ |
||
138 | 138 | |
139 | 139 | public function searchDoctor(Request $request) |
140 | 140 | { |
141 | - if($request->nama == null AND $request->location != null){ |
|
141 | + if($request->nama == null and $request->location != null){ |
|
142 | 142 | $doctor = Doctor::where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
143 | - }elseif ($request->location == null AND $request->nama != null){ |
|
143 | + }elseif ($request->location == null and $request->nama != null){ |
|
144 | 144 | $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->orderBy('name','asc')->paginate(5); |
145 | 145 | }else{ |
146 | 146 | $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
@@ -11,8 +11,7 @@ discard block |
||
11 | 11 | use Psy\Exception\ErrorException; |
12 | 12 | |
13 | 13 | |
14 | -class DoctorController extends Controller |
|
15 | -{ |
|
14 | +class DoctorController extends Controller { |
|
16 | 15 | /** |
17 | 16 | * Returning view with data resource |
18 | 17 | * |
@@ -146,11 +145,11 @@ discard block |
||
146 | 145 | |
147 | 146 | public function searchDoctor(Request $request) |
148 | 147 | { |
149 | - if($request->nama == null AND $request->location != null){ |
|
148 | + if($request->nama == null AND $request->location != null) { |
|
150 | 149 | $doctor = Doctor::where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
151 | - }elseif ($request->location == null AND $request->nama != null){ |
|
150 | + } elseif ($request->location == null AND $request->nama != null) { |
|
152 | 151 | $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->orderBy('name','asc')->paginate(5); |
153 | - }else{ |
|
152 | + } else { |
|
154 | 153 | $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
155 | 154 | } |
156 | 155 | $location = City::orderBy('name','asc')->pluck('name','id'); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | abort(503); |
24 | 24 | |
25 | 25 | $doctors = Doctor::all(); |
26 | - if(!$doctors) { |
|
26 | + if (!$doctors) { |
|
27 | 27 | abort(503); |
28 | 28 | } |
29 | 29 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function store(Request $request) |
56 | 56 | { |
57 | - $this->validate($request,[ |
|
57 | + $this->validate($request, [ |
|
58 | 58 | 'specialty' => 'required', |
59 | 59 | 'name' => 'required|min:3|max:50', |
60 | 60 | 'license' => 'required|min:3|max:191', |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | $doctor->email = $request->input('email'); |
72 | 72 | $doctor->password = Hash::make($request->password); |
73 | 73 | |
74 | - if($doctor->save()) { |
|
75 | - return redirect (route('doctor.index'))->with('success', 'Berhasil Menambahkan Dokter !'); |
|
74 | + if ($doctor->save()) { |
|
75 | + return redirect(route('doctor.index'))->with('success', 'Berhasil Menambahkan Dokter !'); |
|
76 | 76 | } |
77 | 77 | |
78 | - return redirect (route('doctor.index'))->with('failed', 'Gagal menambah dokter !'); |
|
78 | + return redirect(route('doctor.index'))->with('failed', 'Gagal menambah dokter !'); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -86,20 +86,20 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function show($id) |
88 | 88 | { |
89 | - $doctor = Doctor::where('specialization_id',$id)->orderBy('name','asc')->paginate(5); |
|
90 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
89 | + $doctor = Doctor::where('specialization_id', $id)->orderBy('name', 'asc')->paginate(5); |
|
90 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
91 | 91 | $data = [ |
92 | 92 | 'doctor' => $doctor, |
93 | 93 | 'location' => $location |
94 | 94 | ]; |
95 | - return view('listDoctor')->with('data',$data); |
|
95 | + return view('listDoctor')->with('data', $data); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | public function showDoctor($id) |
99 | 99 | { |
100 | 100 | $doctor = Doctor::find($id); |
101 | 101 | |
102 | - return view('viewDoctor')->with('doctor',$doctor); |
|
102 | + return view('viewDoctor')->with('doctor', $doctor); |
|
103 | 103 | } |
104 | 104 | /** |
105 | 105 | * Show the form for editing the specified resource. |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function update(Request $request, $id) |
129 | 129 | { |
130 | - $this->validate($request,[ |
|
130 | + $this->validate($request, [ |
|
131 | 131 | 'name' => 'required|min:3|max:50', |
132 | 132 | 'password' => 'required_with:password_confirmation|same:password_confirmation|min:6', |
133 | 133 | 'password_confirmation' => 'min:6' |
@@ -137,41 +137,41 @@ discard block |
||
137 | 137 | $doctor = Doctor::find($id); |
138 | 138 | $doctor->name = $request->input('name'); |
139 | 139 | $doctor->password = $pass; |
140 | - if($doctor->save()) { |
|
141 | - return redirect (route('doctor.index'))->with('success', 'Doktor berhasil di update !'); |
|
140 | + if ($doctor->save()) { |
|
141 | + return redirect(route('doctor.index'))->with('success', 'Doktor berhasil di update !'); |
|
142 | 142 | } |
143 | 143 | |
144 | - return redirect (route('doctor.edit', $id))->with('failed', 'Gagal memperbaharui dokter !'); |
|
144 | + return redirect(route('doctor.edit', $id))->with('failed', 'Gagal memperbaharui dokter !'); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | public function searchDoctor(Request $request) |
148 | 148 | { |
149 | - if($request->nama == null AND $request->location != null){ |
|
150 | - $doctor = Doctor::where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
|
151 | - }elseif ($request->location == null AND $request->nama != null){ |
|
152 | - $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->orderBy('name','asc')->paginate(5); |
|
153 | - }else{ |
|
154 | - $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
|
149 | + if ($request->nama == null AND $request->location != null) { |
|
150 | + $doctor = Doctor::where('city_id', $request->location)->orderBy('name', 'asc')->paginate(5); |
|
151 | + }elseif ($request->location == null AND $request->nama != null) { |
|
152 | + $doctor = Doctor::where('name', 'LIKE', '%'.$request->nama.'%')->orderBy('name', 'asc')->paginate(5); |
|
153 | + } else { |
|
154 | + $doctor = Doctor::where('name', 'LIKE', '%'.$request->nama.'%')->where('city_id', $request->location)->orderBy('name', 'asc')->paginate(5); |
|
155 | 155 | } |
156 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
156 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
157 | 157 | $data = [ |
158 | 158 | 'doctor' => $doctor, |
159 | 159 | 'location' => $location |
160 | 160 | ]; |
161 | 161 | |
162 | - return view('listDoctor')->with('data',$data); |
|
162 | + return view('listDoctor')->with('data', $data); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | public function searchByRadio(Request $request) |
166 | 166 | { |
167 | - $locationId = City::where('name','LIKE','%'.$request->location.'%')->pluck('id','name'); |
|
168 | - $doctor = Doctor::where('city_id',$locationId)->orderBy('name','asc')->paginate(5); |
|
169 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
167 | + $locationId = City::where('name', 'LIKE', '%'.$request->location.'%')->pluck('id', 'name'); |
|
168 | + $doctor = Doctor::where('city_id', $locationId)->orderBy('name', 'asc')->paginate(5); |
|
169 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
170 | 170 | $data = [ |
171 | 171 | 'doctor'=>$doctor, |
172 | 172 | 'location' => $location |
173 | 173 | ]; |
174 | - return view('listDoctor')->with('data',$data); |
|
174 | + return view('listDoctor')->with('data', $data); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $doctor = Doctor::find($id); |
186 | 186 | $doctor->delete(); |
187 | 187 | |
188 | - return redirect (route('doctor.index')); |
|
188 | + return redirect(route('doctor.index')); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public function index() |
16 | 16 | { |
17 | - $articles = Articles::orderBy('category','asc')->paginate(5); |
|
17 | + $articles = Articles::orderBy('category', 'asc')->paginate(5); |
|
18 | 18 | $data = [ |
19 | 19 | 'articles' => $articles |
20 | 20 | ]; |
@@ -37,20 +37,20 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function store(Request $request) |
39 | 39 | { |
40 | - $this->validate($request,[ |
|
40 | + $this->validate($request, [ |
|
41 | 41 | 'category' => 'required', |
42 | 42 | 'title' => 'required', |
43 | 43 | 'content' => 'required|min:500', |
44 | 44 | 'cover_image' => 'image|nullable|max:3999' |
45 | 45 | ]); |
46 | 46 | |
47 | - if($request->hasFile('cover_image')){ |
|
47 | + if ($request->hasFile('cover_image')) { |
|
48 | 48 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
49 | 49 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
50 | 50 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
51 | 51 | $fileNameToStore = $filename.'_'.time().'.'.$extension; |
52 | 52 | $path = $request->file('cover_image')->storeAs('public/cover_images', $fileNameToStore); |
53 | - }else { |
|
53 | + } else { |
|
54 | 54 | $fileNameToStore = 'noimage.jpg'; |
55 | 55 | } |
56 | 56 | |
@@ -58,15 +58,15 @@ discard block |
||
58 | 58 | $article->category = $request->input('category'); |
59 | 59 | $article->title = $request->input('title'); |
60 | 60 | $article->content = $request->input('content'); |
61 | - if(session('guard') == 'admin') { |
|
61 | + if (session('guard') == 'admin') { |
|
62 | 62 | $article->admin_id = Auth::guard('admin')->user()->id; |
63 | 63 | } else { |
64 | 64 | $article->doctor_id = Auth::guard('doctor')->user()->id; |
65 | 65 | } |
66 | 66 | $article->cover_image = $fileNameToStore; |
67 | 67 | |
68 | - if($article->save()) { |
|
69 | - return redirect (route(session('guard').'.article.index'))->with('success', 'Artikel baru berhasil ditambahkan !'); |
|
68 | + if ($article->save()) { |
|
69 | + return redirect(route(session('guard').'.article.index'))->with('success', 'Artikel baru berhasil ditambahkan !'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | return redirect(route(session('guard').'.article.create'))->with('failed', 'Gagal menambahkan artikel.'); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function show($id) |
80 | 80 | { |
81 | 81 | $article = Articles::find($id); |
82 | - if(!$article) { |
|
82 | + if (!$article) { |
|
83 | 83 | abort(404); |
84 | 84 | } |
85 | 85 | return view('pages.ext.view-article')->with('article', $article); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | $data = [ |
115 | - 'articles' => Articles::where('category', $cat)->orderBy('title','asc')->get(), |
|
115 | + 'articles' => Articles::where('category', $cat)->orderBy('title', 'asc')->get(), |
|
116 | 116 | 'category' => $category, |
117 | 117 | 'cat' => $cat |
118 | 118 | ]; |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | } |
144 | 144 | $data = [ |
145 | 145 | 'articles' => Articles::where('category', $cat) |
146 | - ->where('title','LIKE',$name.'%') |
|
147 | - ->orderBy('title','asc') |
|
146 | + ->where('title', 'LIKE', $name.'%') |
|
147 | + ->orderBy('title', 'asc') |
|
148 | 148 | ->get(), |
149 | 149 | 'category' => $category, |
150 | 150 | 'cat' => $cat |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | { |
158 | 158 | $cari = $request->cari; |
159 | 159 | $articles = Articles::where('category', $cat) |
160 | - ->where('content','LIKE','%'.$cari.'%') |
|
161 | - ->orderBy('title','asc') |
|
160 | + ->where('content', 'LIKE', '%'.$cari.'%') |
|
161 | + ->orderBy('title', 'asc') |
|
162 | 162 | ->get(); |
163 | 163 | $category = null; |
164 | 164 | switch ($cat) { |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | public function edit($id) |
195 | 195 | { |
196 | 196 | $article = Articles::find($id); |
197 | - if(!$article) { |
|
197 | + if (!$article) { |
|
198 | 198 | abort(404); |
199 | 199 | } |
200 | 200 | |
201 | - if($article->writer()['data']->id != Auth::guard(session('guard'))->user()->id) { |
|
201 | + if ($article->writer()[ 'data' ]->id != Auth::guard(session('guard'))->user()->id) { |
|
202 | 202 | return redirect(session('guard').'/article')->with('warning', 'Anda tidak berhak untuk mengubah Artikel tersebut.'); |
203 | 203 | } |
204 | 204 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function update(Request $request, $id) |
218 | 218 | { |
219 | - $this->validate($request,[ |
|
219 | + $this->validate($request, [ |
|
220 | 220 | 'category' => 'required', |
221 | 221 | 'title' => 'required', |
222 | 222 | 'content' => 'required|min:500', |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | ]); |
226 | 226 | |
227 | - if($request->hasFile('cover_image')){ |
|
227 | + if ($request->hasFile('cover_image')) { |
|
228 | 228 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
229 | 229 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
230 | 230 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
@@ -236,15 +236,15 @@ discard block |
||
236 | 236 | $article->category = $request->input('category'); |
237 | 237 | $article->title = $request->input('title'); |
238 | 238 | $article->content = $request->input('content'); |
239 | - if($request->hasFile('cover_image')){ |
|
239 | + if ($request->hasFile('cover_image')) { |
|
240 | 240 | $article->cover_image = $fileNameToStore; |
241 | 241 | } |
242 | 242 | |
243 | - if($article->save()) { |
|
244 | - return redirect (route(session('guard').'.article.index'))->with('success', 'Artikel berhasil diubah !'); |
|
243 | + if ($article->save()) { |
|
244 | + return redirect(route(session('guard').'.article.index'))->with('success', 'Artikel berhasil diubah !'); |
|
245 | 245 | } |
246 | 246 | |
247 | - return redirect (route(session('guard').'.article.edit', $id))->with('failed', 'Gagal mengubah artikel !'); |
|
247 | + return redirect(route(session('guard').'.article.edit', $id))->with('failed', 'Gagal mengubah artikel !'); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -255,11 +255,11 @@ discard block |
||
255 | 255 | { |
256 | 256 | $article = Articles::find($id); |
257 | 257 | |
258 | - if($article->cover_image != 'noimage.jpg'){ |
|
258 | + if ($article->cover_image != 'noimage.jpg') { |
|
259 | 259 | Storage::delete('public/cover_images/'.$article->cover_image); |
260 | 260 | } |
261 | 261 | |
262 | - if($article->delete()) { |
|
262 | + if ($article->delete()) { |
|
263 | 263 | return redirect()->back()->with('success', 'Artikel dihapus !'); |
264 | 264 | } |
265 | 265 |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | use Illuminate\Support\Facades\Auth; |
8 | 8 | use App\Articles; |
9 | 9 | |
10 | -class ArticleController extends Controller |
|
11 | -{ |
|
10 | +class ArticleController extends Controller { |
|
12 | 11 | /** |
13 | 12 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
14 | 13 | */ |
@@ -44,13 +43,13 @@ discard block |
||
44 | 43 | 'cover_image' => 'image|nullable|max:3999' |
45 | 44 | ]); |
46 | 45 | |
47 | - if($request->hasFile('cover_image')){ |
|
46 | + if($request->hasFile('cover_image')) { |
|
48 | 47 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
49 | 48 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
50 | 49 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
51 | 50 | $fileNameToStore = $filename.'_'.time().'.'.$extension; |
52 | 51 | $path = $request->file('cover_image')->storeAs('public/cover_images', $fileNameToStore); |
53 | - }else { |
|
52 | + } else { |
|
54 | 53 | $fileNameToStore = 'noimage.jpg'; |
55 | 54 | } |
56 | 55 | |
@@ -224,7 +223,7 @@ discard block |
||
224 | 223 | |
225 | 224 | ]); |
226 | 225 | |
227 | - if($request->hasFile('cover_image')){ |
|
226 | + if($request->hasFile('cover_image')) { |
|
228 | 227 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
229 | 228 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
230 | 229 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
@@ -236,7 +235,7 @@ discard block |
||
236 | 235 | $article->category = $request->input('category'); |
237 | 236 | $article->title = $request->input('title'); |
238 | 237 | $article->content = $request->input('content'); |
239 | - if($request->hasFile('cover_image')){ |
|
238 | + if($request->hasFile('cover_image')) { |
|
240 | 239 | $article->cover_image = $fileNameToStore; |
241 | 240 | } |
242 | 241 | |
@@ -255,7 +254,7 @@ discard block |
||
255 | 254 | { |
256 | 255 | $article = Articles::find($id); |
257 | 256 | |
258 | - if($article->cover_image != 'noimage.jpg'){ |
|
257 | + if($article->cover_image != 'noimage.jpg') { |
|
259 | 258 | Storage::delete('public/cover_images/'.$article->cover_image); |
260 | 259 | } |
261 | 260 |
@@ -3,7 +3,7 @@ |
||
3 | 3 | namespace App\Http\Controllers; |
4 | 4 | |
5 | 5 | use Illuminate\Http\Request; |
6 | -Use Illuminate\Support\Facades\Storage; |
|
6 | +use Illuminate\Support\Facades\Storage; |
|
7 | 7 | use Illuminate\Support\Facades\Auth; |
8 | 8 | use App\Articles; |
9 | 9 |
@@ -22,7 +22,7 @@ |
||
22 | 22 | } |
23 | 23 | |
24 | 24 | public function trimStr(string $string) { |
25 | - if(strlen($string) > 200) { |
|
25 | + if (strlen($string) > 200) { |
|
26 | 26 | return substr($string, 0, 200).'...'; |
27 | 27 | } |
28 | 28 | } |
@@ -4,8 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Illuminate\Database\Eloquent\Model; |
6 | 6 | |
7 | -class Thread extends Model |
|
8 | -{ |
|
7 | +class Thread extends Model { |
|
9 | 8 | protected $table = 'threads'; |
10 | 9 | |
11 | 10 | protected $dates = [ |
@@ -13,15 +12,18 @@ discard block |
||
13 | 12 | 'updated_at' |
14 | 13 | ]; |
15 | 14 | |
16 | - public function topic() { |
|
15 | + public function topic() |
|
16 | + { |
|
17 | 17 | return $this->belongsTo('App\ThreadTopic', 'id_topic'); |
18 | 18 | } |
19 | 19 | |
20 | - public function user() { |
|
20 | + public function user() |
|
21 | + { |
|
21 | 22 | return $this->belongsTo('App\User'); |
22 | 23 | } |
23 | 24 | |
24 | - public function trimStr(string $string) { |
|
25 | + public function trimStr(string $string) |
|
26 | + { |
|
25 | 27 | if(strlen($string) > 200) { |
26 | 28 | return substr($string, 0, 200).'...'; |
27 | 29 | } |
@@ -4,8 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Illuminate\Database\Eloquent\Model; |
6 | 6 | |
7 | -class City extends Model |
|
8 | -{ |
|
7 | +class City extends Model { |
|
9 | 8 | /** |
10 | 9 | * @var string |
11 | 10 | */ |
@@ -37,7 +36,8 @@ discard block |
||
37 | 36 | return $this->hasMany('App\Hospital'); |
38 | 37 | } |
39 | 38 | |
40 | - public function doctor() { |
|
39 | + public function doctor() |
|
40 | + { |
|
41 | 41 | return $this->belongsTo('App\Doctor'); |
42 | 42 | } |
43 | 43 | } |
@@ -4,8 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use Illuminate\Database\Eloquent\Model; |
6 | 6 | |
7 | -class ThreadTopic extends Model |
|
8 | -{ |
|
7 | +class ThreadTopic extends Model { |
|
9 | 8 | protected $table = 'thread_topics'; |
10 | 9 | |
11 | 10 | protected $dates = [ |
@@ -4,8 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use Illuminate\Http\Request; |
6 | 6 | |
7 | -class ThreadAnswerController extends Controller |
|
8 | -{ |
|
7 | +class ThreadAnswerController extends Controller { |
|
9 | 8 | /** |
10 | 9 | * Display a listing of the resource. |
11 | 10 | * |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | { |
12 | 12 | public function __construct() |
13 | 13 | { |
14 | - $this->middleware('auth', ['except' => [ |
|
14 | + $this->middleware('auth', [ 'except' => [ |
|
15 | 15 | 'index', 'show' |
16 | - ]]); |
|
16 | + ] ]); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function create() |
37 | 37 | { |
38 | 38 | $threads = Thread::orderBy('created_at', 'asc')->get(); |
39 | - return view('ask-form')->with('threads', $threads);; |
|
39 | + return view('ask-form')->with('threads', $threads); ; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | |
56 | 56 | $topic = $this->addTopic($request->input('topic')); |
57 | 57 | |
58 | - if($topic != null) { |
|
58 | + if ($topic != null) { |
|
59 | 59 | $thread = new Thread; |
60 | 60 | $thread->user_id = $this->currentUser()->id; |
61 | 61 | $thread->id_topic = $topic->id; |
62 | 62 | $thread->question = $request->input('question'); |
63 | 63 | |
64 | - if($thread->save()) { |
|
64 | + if ($thread->save()) { |
|
65 | 65 | return redirect(route('user.thread.index'))->with('success', 'Pertanyaan dikirim !'); |
66 | 66 | } |
67 | 67 | return redirect()->back()->with('failed', 'Gagal mengirim pertanyaan, silahkan coba lagi nanti.'); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | private function addTopic(string $topic) { |
127 | 127 | $new = new ThreadTopic; |
128 | 128 | $new->topic_name = $topic; |
129 | - if($new->save()) { |
|
129 | + if ($new->save()) { |
|
130 | 130 | return $new; |
131 | 131 | } |
132 | 132 | return null; |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | use App\Thread; |
8 | 8 | use App\ThreadTopic; |
9 | 9 | |
10 | -class ThreadAskController extends Controller |
|
11 | -{ |
|
10 | +class ThreadAskController extends Controller { |
|
12 | 11 | public function __construct() |
13 | 12 | { |
14 | 13 | $this->middleware('auth', ['except' => [ |
@@ -115,7 +114,8 @@ discard block |
||
115 | 114 | } |
116 | 115 | |
117 | 116 | |
118 | - private function currentUser() { |
|
117 | + private function currentUser() |
|
118 | + { |
|
119 | 119 | return Auth::guard('web')->user(); |
120 | 120 | } |
121 | 121 | |
@@ -123,7 +123,8 @@ discard block |
||
123 | 123 | * @param string $topic |
124 | 124 | * @return ThreadTopic|null |
125 | 125 | */ |
126 | - private function addTopic(string $topic) { |
|
126 | + private function addTopic(string $topic) |
|
127 | + { |
|
127 | 128 | $new = new ThreadTopic; |
128 | 129 | $new->topic_name = $topic; |
129 | 130 | if($new->save()) { |