@@ -12,9 +12,9 @@ discard block |
||
| 12 | 12 | { |
| 13 | 13 | public function __construct() |
| 14 | 14 | { |
| 15 | - $this->middleware('auth', ['except' => [ |
|
| 15 | + $this->middleware('auth', [ 'except' => [ |
|
| 16 | 16 | 'index', 'show' |
| 17 | - ]]); |
|
| 17 | + ] ]); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | |
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $topic = $this->addTopic($request->input('topic')); |
| 64 | 64 | |
| 65 | - if($topic != null) { |
|
| 65 | + if ($topic != null) { |
|
| 66 | 66 | $thread = new Thread; |
| 67 | 67 | $thread->user_id = $this->currentUser()->id; |
| 68 | 68 | $thread->id_topic = $topic->id; |
| 69 | 69 | $thread->question = $request->input('question'); |
| 70 | 70 | |
| 71 | 71 | $log = null; |
| 72 | - if($thread->save()) { |
|
| 72 | + if ($thread->save()) { |
|
| 73 | 73 | $log = Common::registerLog([ |
| 74 | 74 | 'action' => "membuat diskusi baru.", |
| 75 | 75 | 'target' => 'thread', |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | ]); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if($log != null && $log == true) { |
|
| 83 | + if ($log != null && $log == true) { |
|
| 84 | 84 | return redirect(route('user.thread.index'))->with('success', 'Pertanyaan dikirim !'); |
| 85 | 85 | } |
| 86 | 86 | return redirect()->back()->with('failed', 'Gagal mengirim pertanyaan, silahkan coba lagi nanti.'); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | public function show($id) |
| 98 | 98 | { |
| 99 | 99 | $thread = Thread::find($id); |
| 100 | - if(!$thread) { |
|
| 100 | + if (!$thread) { |
|
| 101 | 101 | abort(404); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | $user = $this->currentUser(); |
| 121 | 121 | $thread = Thread::find($id); |
| 122 | - if($thread->user_id != $user->id) { |
|
| 122 | + if ($thread->user_id != $user->id) { |
|
| 123 | 123 | return redirect()->back()->with('warning', 'Anda tidak berhak mengakses laman tersebut.'); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if($thread->doctor_id != null) { |
|
| 126 | + if ($thread->doctor_id != null) { |
|
| 127 | 127 | return redirect()->back()->with('warning', 'Tidak dapat mengubah pertanyaan karena sudah terjawab, silahkan tanyakan pertanyaan baru.'); |
| 128 | 128 | } |
| 129 | 129 | $threads = Thread::orderBy('created_at', 'desc')->paginate(5); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | { |
| 149 | 149 | $user = $this->currentUser(); |
| 150 | 150 | $thread = Thread::find($id); |
| 151 | - if($thread->user_id != $user->id) { |
|
| 151 | + if ($thread->user_id != $user->id) { |
|
| 152 | 152 | return redirect()->back()->with('warning', 'Anda tidak berhak mengubah ulasan tersebut.'); |
| 153 | 153 | } |
| 154 | 154 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | $thread->topic = $request->input('topic'); |
| 161 | 161 | $thread->question = $request->input('question'); |
| 162 | - if($thread->save()) { |
|
| 162 | + if ($thread->save()) { |
|
| 163 | 163 | return redirect(route('user.thread.show', $thread->id))->with('success', 'Berhasil mengubah ulasan !'); |
| 164 | 164 | } |
| 165 | 165 | return redirect(route('user.thread.show', $thread->id))->with('success', 'Berhasil mengubah ulasan !'); |
@@ -175,18 +175,18 @@ discard block |
||
| 175 | 175 | { |
| 176 | 176 | $user = $this->currentUser(); |
| 177 | 177 | $thread = Thread::find($id); |
| 178 | - if($thread->user_id != $user->id) { |
|
| 178 | + if ($thread->user_id != $user->id) { |
|
| 179 | 179 | return redirect()->back()->with('warning', 'Anda tidak berhak menghapus ulasan tersebut.'); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | $unreg = null; |
| 183 | - if($thread->delete() && $this->deleteTopic($thread->id_topic)) { |
|
| 183 | + if ($thread->delete() && $this->deleteTopic($thread->id_topic)) { |
|
| 184 | 184 | $unreg = Common::unregisterLog([ |
| 185 | 185 | 'target' => 'thread', |
| 186 | 186 | 'target_id' => $id |
| 187 | 187 | ]); |
| 188 | 188 | } |
| 189 | - if($unreg != null && $unreg) { |
|
| 189 | + if ($unreg != null && $unreg) { |
|
| 190 | 190 | return redirect(route('user.profile'))->with('success', 'Ulasan dihapus !'); |
| 191 | 191 | } |
| 192 | 192 | return redirect()->back()->with('failed', 'Gagal menghapus ulasan.'); |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | { |
| 211 | 211 | $new = new ThreadTopic; |
| 212 | 212 | $new->topic_name = $topic; |
| 213 | - if($new->save()) { |
|
| 213 | + if ($new->save()) { |
|
| 214 | 214 | return $new; |
| 215 | 215 | } |
| 216 | 216 | return null; |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | private function deleteTopic($id) |
| 226 | 226 | { |
| 227 | 227 | $topic = ThreadTopic::find($id); |
| 228 | - if($topic->delete()) { |
|
| 228 | + if ($topic->delete()) { |
|
| 229 | 229 | return true; |
| 230 | 230 | } |
| 231 | 231 | return false; |
@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | { |
| 12 | 12 | public function __construct() |
| 13 | 13 | { |
| 14 | - $this->middleware('auth:admin', ['except' => [ |
|
| 14 | + $this->middleware('auth:admin', [ 'except' => [ |
|
| 15 | 15 | 'index', 'show' |
| 16 | - ]]); |
|
| 16 | + ] ]); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | $threads = null; |
| 28 | 28 | $count = null; |
| 29 | - if($query == "all") { |
|
| 29 | + if ($query == "all") { |
|
| 30 | 30 | $threads = Thread::orderBy('created_at', 'desc')->paginate(15); |
| 31 | - } elseif($query == "answered") { |
|
| 31 | + } elseif ($query == "answered") { |
|
| 32 | 32 | $threads = Thread::where('status', true) |
| 33 | 33 | ->orderBy('created_at', 'desc') |
| 34 | 34 | ->paginate(15); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | public function show($id) |
| 62 | 62 | { |
| 63 | 63 | $thread = Thread::find($id); |
| 64 | - if(!$thread) { |
|
| 64 | + if (!$thread) { |
|
| 65 | 65 | abort(404); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -84,14 +84,14 @@ discard block |
||
| 84 | 84 | { |
| 85 | 85 | $thread = Thread::find($id); |
| 86 | 86 | $unreg = null; |
| 87 | - if($thread->delete() && $this->deleteTopic($thread->id_topic)) { |
|
| 87 | + if ($thread->delete() && $this->deleteTopic($thread->id_topic)) { |
|
| 88 | 88 | $unreg = Common::unregisterLog([ |
| 89 | 89 | 'target' => 'thread', |
| 90 | 90 | 'target_id' => $id |
| 91 | 91 | ]); |
| 92 | 92 | } |
| 93 | - if($unreg != null && $unreg) { |
|
| 94 | - return redirect(route('admin.thread.index', ['query' => "all"]))->with('success', 'Diskusi dihapus !'); |
|
| 93 | + if ($unreg != null && $unreg) { |
|
| 94 | + return redirect(route('admin.thread.index', [ 'query' => "all" ]))->with('success', 'Diskusi dihapus !'); |
|
| 95 | 95 | } |
| 96 | 96 | return redirect()->back()->with('failed', 'Gagal menghapus diskusi.'); |
| 97 | 97 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | public function deleteTopic($id) |
| 107 | 107 | { |
| 108 | 108 | $topic = ThreadTopic::find($id); |
| 109 | - if($topic->delete()) { |
|
| 109 | + if ($topic->delete()) { |
|
| 110 | 110 | return true; |
| 111 | 111 | } |
| 112 | 112 | return false; |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function index() |
| 19 | 19 | { |
| 20 | - $hospital = Hospital::orderBy('city_id','asc')->paginate(10); |
|
| 20 | + $hospital = Hospital::orderBy('city_id', 'asc')->paginate(10); |
|
| 21 | 21 | $data = [ |
| 22 | 22 | 'role' => session('role'), |
| 23 | 23 | 'hospital' => $hospital |
| 24 | 24 | ]; |
| 25 | - return view('pages.hospital')->with('data',$data); |
|
| 25 | + return view('pages.hospital')->with('data', $data); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | $hospital->public_services = $request->input('public_services'); |
| 64 | 64 | $hospital->cover_images_id = 1; |
| 65 | 65 | |
| 66 | - if($hospital->save()) { |
|
| 67 | - return redirect (route('hospital.index'))->with('success', 'Rumah sakit berhasil di tambahkan !'); |
|
| 66 | + if ($hospital->save()) { |
|
| 67 | + return redirect(route('hospital.index'))->with('success', 'Rumah sakit berhasil di tambahkan !'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - return redirect (route('hospital.index'))->with('failed', 'Gagal menambahkan rumah sakit !'); |
|
| 70 | + return redirect(route('hospital.index'))->with('failed', 'Gagal menambahkan rumah sakit !'); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function show($id) |
| 80 | 80 | { |
| 81 | 81 | $hospital = Hospital::find($id); |
| 82 | - if(!$hospital) { |
|
| 82 | + if (!$hospital) { |
|
| 83 | 83 | abort(401); |
| 84 | 84 | } |
| 85 | 85 | $data = [ |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | $hospital->public_services = $request->input('public_services'); |
| 137 | 137 | $hospital->cover_images_id = 1; |
| 138 | 138 | |
| 139 | - if($hospital->save()) { |
|
| 140 | - return redirect (route('hospital.index'))->with('success', 'Rumah sakit berhasil di perbaharui'); |
|
| 139 | + if ($hospital->save()) { |
|
| 140 | + return redirect(route('hospital.index'))->with('success', 'Rumah sakit berhasil di perbaharui'); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - return redirect (route('hospital.edit', $id))->with('failed', 'Gagal memperbaharui rumah sakit !'); |
|
| 143 | + return redirect(route('hospital.edit', $id))->with('failed', 'Gagal memperbaharui rumah sakit !'); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $hospital = Hospital::find($id); |
| 155 | 155 | $rooms = $this->deleteRoomsAndRoomDetail($id); |
| 156 | 156 | |
| 157 | - if($hospital->delete() && $rooms) { |
|
| 157 | + if ($hospital->delete() && $rooms) { |
|
| 158 | 158 | return redirect(route('hospital.index')); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | ->where('hospital_id', '=', $hospital_id) |
| 175 | 175 | ->delete(); |
| 176 | 176 | |
| 177 | - if($delroom && $deldetail) { |
|
| 177 | + if ($delroom && $deldetail) { |
|
| 178 | 178 | return true; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | $rooms = DB::table('rooms') |
| 191 | 191 | ->selectRaw(DB::raw('rooms.*')) |
| 192 | 192 | ->leftJoin('room_details', 'rooms.id', '=', 'room_details.room_id') |
| 193 | - ->where('room_details.hospital_id','=',$hospital_id) |
|
| 193 | + ->where('room_details.hospital_id', '=', $hospital_id) |
|
| 194 | 194 | ->get(); |
| 195 | 195 | |
| 196 | 196 | return $rooms; |
@@ -198,13 +198,13 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | public function indexUser() |
| 200 | 200 | { |
| 201 | - $location = City::orderBy('name','asc')->pluck('name', 'id'); |
|
| 201 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
| 202 | 202 | $img = 'storage/images/hospital-icon.jpg'; |
| 203 | 203 | $data = [ |
| 204 | 204 | 'img' => $img, |
| 205 | 205 | 'location' => $location |
| 206 | 206 | ]; |
| 207 | - return view ('SearchRS')->with('data',$data); |
|
| 207 | + return view('SearchRS')->with('data', $data); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | public function showList() |
@@ -214,30 +214,30 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | public function searchHospital(Request $request) |
| 216 | 216 | { |
| 217 | - if($request->nama == null AND $request->location != null){ |
|
| 218 | - $hospital = Hospital::where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
|
| 219 | - }elseif ($request->location == null AND $request->nama != null){ |
|
| 220 | - $hospital = Hospital::where('biography','LIKE','%'.$request->nama.'%')->orderBy('name','asc')->paginate(5); |
|
| 221 | - }else{ |
|
| 222 | - $hospital = Hospital::where('biography','LIKE','%'.$request->nama.'%')->where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
|
| 217 | + if ($request->nama == null AND $request->location != null) { |
|
| 218 | + $hospital = Hospital::where('city_id', $request->location)->orderBy('name', 'asc')->paginate(5); |
|
| 219 | + }elseif ($request->location == null AND $request->nama != null) { |
|
| 220 | + $hospital = Hospital::where('biography', 'LIKE', '%'.$request->nama.'%')->orderBy('name', 'asc')->paginate(5); |
|
| 221 | + } else { |
|
| 222 | + $hospital = Hospital::where('biography', 'LIKE', '%'.$request->nama.'%')->where('city_id', $request->location)->orderBy('name', 'asc')->paginate(5); |
|
| 223 | 223 | } |
| 224 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
| 224 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
| 225 | 225 | $data = [ |
| 226 | 226 | 'hospital' => $hospital, |
| 227 | 227 | 'location' => $location |
| 228 | 228 | ]; |
| 229 | - return view ('listHospital')->with('data',$data); |
|
| 229 | + return view('listHospital')->with('data', $data); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | public function searchContent($content) |
| 233 | 233 | { |
| 234 | - $hospital = Hospital::where('biography','LIKE','%'.$content.'%')->orderBy('name','asc')->paginate(5); |
|
| 235 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
| 234 | + $hospital = Hospital::where('biography', 'LIKE', '%'.$content.'%')->orderBy('name', 'asc')->paginate(5); |
|
| 235 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
| 236 | 236 | $data = [ |
| 237 | 237 | 'hospital' => $hospital, |
| 238 | 238 | 'location' => $location |
| 239 | 239 | ]; |
| 240 | - return view ('listHospital')->with('data',$data); |
|
| 240 | + return view('listHospital')->with('data', $data); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | public function viewHospital($id) |
@@ -247,6 +247,6 @@ discard block |
||
| 247 | 247 | 'hospital' => $hospital, |
| 248 | 248 | 'room' => $this->getRooms($id), |
| 249 | 249 | ]; |
| 250 | - return view ('viewhospital')->with('data',$data); |
|
| 250 | + return view('viewhospital')->with('data', $data); |
|
| 251 | 251 | } |
| 252 | 252 | } |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | public function __construct() |
| 22 | 22 | { |
| 23 | - $this->middleware('auth', ['except' => [ |
|
| 23 | + $this->middleware('auth', [ 'except' => [ |
|
| 24 | 24 | 'index', |
| 25 | 25 | 'showArticle' |
| 26 | - ]]); |
|
| 26 | + ] ]); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | public function index() |
| 34 | 34 | { |
| 35 | 35 | $threads = Thread::orderBy('created_at', 'desc')->paginate(5); |
| 36 | - $articles = Articles::where('category','penyakit')->orderBy('created_at','desc')->take(3)->get(); |
|
| 36 | + $articles = Articles::where('category', 'penyakit')->orderBy('created_at', 'desc')->take(3)->get(); |
|
| 37 | 37 | $data = [ |
| 38 | 38 | 'threads' => $threads, |
| 39 | 39 | 'articles' => $articles |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | public function profile($query) |
| 52 | 52 | { |
| 53 | 53 | $threads = null; |
| 54 | - if($query == "all") { |
|
| 54 | + if ($query == "all") { |
|
| 55 | 55 | $threads = Thread::where('user_id', $this->currentUser()->id) |
| 56 | 56 | ->orderBy('updated_at', 'desc') |
| 57 | 57 | ->paginate(3); |
| 58 | - } elseif($query == "answered") { |
|
| 58 | + } elseif ($query == "answered") { |
|
| 59 | 59 | $threads = Thread::where('user_id', $this->currentUser()->id) |
| 60 | 60 | ->where('status', true) |
| 61 | 61 | ->orderBy('updated_at', 'desc') |
@@ -78,11 +78,11 @@ discard block |
||
| 78 | 78 | public function edit($id) |
| 79 | 79 | { |
| 80 | 80 | $user = $this->currentUser(); |
| 81 | - if($user->id == $id) { |
|
| 81 | + if ($user->id == $id) { |
|
| 82 | 82 | $data = [ |
| 83 | 83 | 'user' => $user |
| 84 | 84 | ]; |
| 85 | - return view ('profile-edit')->with('data', $data); |
|
| 85 | + return view('profile-edit')->with('data', $data); |
|
| 86 | 86 | } |
| 87 | 87 | return redirect()->back()->with('warning', 'Anda tidak berhak untuk mengakses laman tersebut.'); |
| 88 | 88 | } |
@@ -95,11 +95,11 @@ discard block |
||
| 95 | 95 | public function editPass($id) |
| 96 | 96 | { |
| 97 | 97 | $user = $this->currentUser(); |
| 98 | - if($user->id == $id) { |
|
| 98 | + if ($user->id == $id) { |
|
| 99 | 99 | $data = [ |
| 100 | 100 | 'user' => $user |
| 101 | 101 | ]; |
| 102 | - return view ('profile-password')->with('data', $data); |
|
| 102 | + return view('profile-password')->with('data', $data); |
|
| 103 | 103 | } |
| 104 | 104 | return redirect()->back()->with('warning', 'Anda tidak berhak untuk mengakses laman tersebut.'); |
| 105 | 105 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function update(Request $request, $id) |
| 115 | 115 | { |
| 116 | - $this->validate($request,[ |
|
| 116 | + $this->validate($request, [ |
|
| 117 | 117 | 'name' => 'required|min:3', |
| 118 | 118 | 'email' => 'required|email', |
| 119 | 119 | 'image' => 'image|nullable|max:3999' |
@@ -122,9 +122,9 @@ discard block |
||
| 122 | 122 | $img = null; |
| 123 | 123 | $user = $this->currentUser(); |
| 124 | 124 | |
| 125 | - if($request->hasFile('image')) { |
|
| 125 | + if ($request->hasFile('image')) { |
|
| 126 | 126 | |
| 127 | - if( $user->profile_picture != "user-default.jpg" && |
|
| 127 | + if ($user->profile_picture != "user-default.jpg" && |
|
| 128 | 128 | $user->profile_picture != "user-default-male.png" && |
| 129 | 129 | $user->profile_picture != "user-default-female.png") { |
| 130 | 130 | |
@@ -151,14 +151,14 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | |
| 154 | - if($this->currentUser()->id == $id) { |
|
| 154 | + if ($this->currentUser()->id == $id) { |
|
| 155 | 155 | $user->name = $request->input('name'); |
| 156 | 156 | $user->biography = $request->input('bio'); |
| 157 | 157 | $user->gender = $request->input('gender'); |
| 158 | 158 | $user->profile_picture = $img; |
| 159 | 159 | $user->save(); |
| 160 | 160 | |
| 161 | - return redirect (route('user.profile.edit', ['id' => $id]))->with('success', 'Profil berhasil diperbarui !'); |
|
| 161 | + return redirect(route('user.profile.edit', [ 'id' => $id ]))->with('success', 'Profil berhasil diperbarui !'); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | return redirect()->back()->with('warning', 'Anda tidak berhak untuk mengakses laman tersebut.'); |
@@ -180,10 +180,10 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | $user = $this->currentUser(); |
| 182 | 182 | |
| 183 | - if($this->validatePass($request->input('old_password'))) { |
|
| 183 | + if ($this->validatePass($request->input('old_password'))) { |
|
| 184 | 184 | $user->password = Hash::make($request->input('new_password')); |
| 185 | 185 | |
| 186 | - if($user->save()) { |
|
| 186 | + if ($user->save()) { |
|
| 187 | 187 | session()->flush(); |
| 188 | 188 | |
| 189 | 189 | return redirect(route('login'))->with('success', 'Password berhasil diubah ! Silahkan login kembali.'); |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | public function showArticle($id) |
| 202 | 202 | { |
| 203 | 203 | $article = Articles::find($id); |
| 204 | - return view('viewarticle')->with('article',$article); |
|
| 204 | + return view('viewarticle')->with('article', $article); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | |
@@ -213,23 +213,23 @@ discard block |
||
| 213 | 213 | $user = $this->currentUser(); |
| 214 | 214 | $img = null; |
| 215 | 215 | |
| 216 | - if( $user->profile_picture != "user-default.jpg" && |
|
| 216 | + if ($user->profile_picture != "user-default.jpg" && |
|
| 217 | 217 | $user->profile_picture != "user-default-male.png" && |
| 218 | 218 | $user->profile_picture != "user-default-female.png") { |
| 219 | 219 | |
| 220 | 220 | Storage::delete('public/user_images/'.$user->profile_picture); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - if( $user->gender != null && $user->gender == "Laki - laki") { |
|
| 223 | + if ($user->gender != null && $user->gender == "Laki - laki") { |
|
| 224 | 224 | $img = "user-default-male.png"; |
| 225 | - } elseif($user->gender != null && $user->gender == "Perempuan") { |
|
| 225 | + } elseif ($user->gender != null && $user->gender == "Perempuan") { |
|
| 226 | 226 | $img = "user-default-female.png"; |
| 227 | 227 | } else { |
| 228 | 228 | $img = "user-default.jpg"; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | $user->profile_picture = $img; |
| 232 | - if($user->save()) { |
|
| 232 | + if ($user->save()) { |
|
| 233 | 233 | return redirect(route('user.profile.edit', $user->id))->with('success', 'Foto profil dihapus !'); |
| 234 | 234 | } |
| 235 | 235 | } |
@@ -241,14 +241,14 @@ discard block |
||
| 241 | 241 | public function destroy() |
| 242 | 242 | { |
| 243 | 243 | $user = $this->currentUser(); |
| 244 | - if( $user->profile_picture != "user-default.jpg" && |
|
| 244 | + if ($user->profile_picture != "user-default.jpg" && |
|
| 245 | 245 | $user->profile_picture != "user-default-male.png" && |
| 246 | 246 | $user->profile_picture != "user-default-female.png") { |
| 247 | 247 | |
| 248 | 248 | Storage::delete('public/user_images/'.$user->profile_picture); |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - if($user->delete()) { |
|
| 251 | + if ($user->delete()) { |
|
| 252 | 252 | session()->flush(); |
| 253 | 253 | return redirect(route('home'))->with('success', 'Akun berhasil dihapus !'); |
| 254 | 254 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | private function validatePass(string $oldPassword) |
| 272 | 272 | { |
| 273 | 273 | $user = $this->currentUser(); |
| 274 | - if(Hash::check($oldPassword, $user->password)) { |
|
| 274 | + if (Hash::check($oldPassword, $user->password)) { |
|
| 275 | 275 | return true; |
| 276 | 276 | } |
| 277 | 277 | return false; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function index() |
| 17 | 17 | { |
| 18 | - $articles = Articles::orderBy('created_at','desc')->paginate(15); |
|
| 18 | + $articles = Articles::orderBy('created_at', 'desc')->paginate(15); |
|
| 19 | 19 | $data = [ |
| 20 | 20 | 'articles' => $articles |
| 21 | 21 | ]; |
@@ -38,20 +38,20 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function store(Request $request) |
| 40 | 40 | { |
| 41 | - $this->validate($request,[ |
|
| 41 | + $this->validate($request, [ |
|
| 42 | 42 | 'category' => 'required', |
| 43 | 43 | 'title' => 'required', |
| 44 | 44 | 'content' => 'required|min:500', |
| 45 | 45 | 'cover_image' => 'image|nullable|max:3999' |
| 46 | 46 | ]); |
| 47 | 47 | |
| 48 | - if($request->hasFile('cover_image')){ |
|
| 48 | + if ($request->hasFile('cover_image')) { |
|
| 49 | 49 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
| 50 | 50 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
| 51 | 51 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
| 52 | 52 | $fileNameToStore = $filename.'_'.time().'.'.$extension; |
| 53 | 53 | $path = $request->file('cover_image')->storeAs('public/cover_images', $fileNameToStore); |
| 54 | - }else { |
|
| 54 | + } else { |
|
| 55 | 55 | $fileNameToStore = 'noimage.jpg'; |
| 56 | 56 | } |
| 57 | 57 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $article->category = $request->input('category'); |
| 60 | 60 | $article->title = $request->input('title'); |
| 61 | 61 | $article->content = $request->input('content'); |
| 62 | - if(session('guard') == 'admin') { |
|
| 62 | + if (session('guard') == 'admin') { |
|
| 63 | 63 | $article->admin_id = Auth::guard('admin')->user()->id; |
| 64 | 64 | } else { |
| 65 | 65 | $article->doctor_id = Auth::guard('doctor')->user()->id; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $article->cover_image = $fileNameToStore; |
| 68 | 68 | |
| 69 | 69 | $log = null; |
| 70 | - if($article->save()) { |
|
| 70 | + if ($article->save()) { |
|
| 71 | 71 | $log = Common::registerLog([ |
| 72 | 72 | 'action' => "membuat artikel baru.", |
| 73 | 73 | 'target' => 'article', |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | ]); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if($log != null && $log == true) { |
|
| 82 | - return redirect (route(session('guard').'.article.index'))->with('success', 'Artikel baru berhasil ditambahkan !'); |
|
| 81 | + if ($log != null && $log == true) { |
|
| 82 | + return redirect(route(session('guard').'.article.index'))->with('success', 'Artikel baru berhasil ditambahkan !'); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | return redirect(route(session('guard').'.article.create'))->with('failed', 'Gagal menambahkan artikel.'); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | public function show($id) |
| 93 | 93 | { |
| 94 | 94 | $article = Articles::find($id); |
| 95 | - if(!$article) { |
|
| 95 | + if (!$article) { |
|
| 96 | 96 | abort(404); |
| 97 | 97 | } |
| 98 | 98 | return view('pages.ext.view-article')->with('article', $article); |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | $data = [ |
| 128 | - 'articles' => Articles::where('category', $cat)->orderBy('title','asc')->get(), |
|
| 128 | + 'articles' => Articles::where('category', $cat)->orderBy('title', 'asc')->get(), |
|
| 129 | 129 | 'category' => $category, |
| 130 | 130 | 'cat' => $cat |
| 131 | 131 | ]; |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | $data = [ |
| 158 | 158 | 'articles' => Articles::where('category', $cat) |
| 159 | - ->where('title','LIKE',$name.'%') |
|
| 160 | - ->orderBy('title','asc') |
|
| 159 | + ->where('title', 'LIKE', $name.'%') |
|
| 160 | + ->orderBy('title', 'asc') |
|
| 161 | 161 | ->get(), |
| 162 | 162 | 'category' => $category, |
| 163 | 163 | 'cat' => $cat |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | { |
| 171 | 171 | $cari = $request->cari; |
| 172 | 172 | $articles = Articles::where('category', $cat) |
| 173 | - ->where('content','LIKE','%'.$cari.'%') |
|
| 174 | - ->orderBy('title','asc') |
|
| 173 | + ->where('content', 'LIKE', '%'.$cari.'%') |
|
| 174 | + ->orderBy('title', 'asc') |
|
| 175 | 175 | ->get(); |
| 176 | 176 | $category = null; |
| 177 | 177 | switch ($cat) { |
@@ -207,11 +207,11 @@ discard block |
||
| 207 | 207 | public function edit($id) |
| 208 | 208 | { |
| 209 | 209 | $article = Articles::find($id); |
| 210 | - if(!$article) { |
|
| 210 | + if (!$article) { |
|
| 211 | 211 | abort(404); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - if($article->writer()['data']->id != Auth::guard(session('guard'))->user()->id) { |
|
| 214 | + if ($article->writer()[ 'data' ]->id != Auth::guard(session('guard'))->user()->id) { |
|
| 215 | 215 | return redirect(session('guard').'/article')->with('warning', 'Anda tidak berhak untuk mengubah Artikel tersebut.'); |
| 216 | 216 | } |
| 217 | 217 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | public function update(Request $request, $id) |
| 231 | 231 | { |
| 232 | - $this->validate($request,[ |
|
| 232 | + $this->validate($request, [ |
|
| 233 | 233 | 'category' => 'required', |
| 234 | 234 | 'title' => 'required', |
| 235 | 235 | 'content' => 'required|min:500', |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | ]); |
| 239 | 239 | |
| 240 | - if($request->hasFile('cover_image')){ |
|
| 240 | + if ($request->hasFile('cover_image')) { |
|
| 241 | 241 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
| 242 | 242 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
| 243 | 243 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
@@ -249,12 +249,12 @@ discard block |
||
| 249 | 249 | $article->category = $request->input('category'); |
| 250 | 250 | $article->title = $request->input('title'); |
| 251 | 251 | $article->content = $request->input('content'); |
| 252 | - if($request->hasFile('cover_image')){ |
|
| 252 | + if ($request->hasFile('cover_image')) { |
|
| 253 | 253 | $article->cover_image = $fileNameToStore; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | $log = null; |
| 257 | - if($article->save()) { |
|
| 257 | + if ($article->save()) { |
|
| 258 | 258 | $log = Common::registerLog([ |
| 259 | 259 | 'action' => "membuat perubahan pada artikelnya.", |
| 260 | 260 | 'target' => 'article', |
@@ -265,11 +265,11 @@ discard block |
||
| 265 | 265 | ]); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if($log != null && $log == true) { |
|
| 269 | - return redirect (route(session('guard').'.article.index'))->with('success', 'Artikel berhasil diubah !'); |
|
| 268 | + if ($log != null && $log == true) { |
|
| 269 | + return redirect(route(session('guard').'.article.index'))->with('success', 'Artikel berhasil diubah !'); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - return redirect (route(session('guard').'.article.edit', $id))->with('failed', 'Gagal mengubah artikel !'); |
|
| 272 | + return redirect(route(session('guard').'.article.edit', $id))->with('failed', 'Gagal mengubah artikel !'); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -280,18 +280,18 @@ discard block |
||
| 280 | 280 | { |
| 281 | 281 | $article = Articles::find($id); |
| 282 | 282 | |
| 283 | - if($article->cover_image != 'noimage.jpg'){ |
|
| 283 | + if ($article->cover_image != 'noimage.jpg') { |
|
| 284 | 284 | Storage::delete('public/cover_images/'.$article->cover_image); |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | $unreg = null; |
| 288 | - if($article->delete()) { |
|
| 288 | + if ($article->delete()) { |
|
| 289 | 289 | $unreg = Common::unregisterLog([ |
| 290 | 290 | 'target' => 'article', |
| 291 | 291 | 'target_id' => $id |
| 292 | 292 | ]); |
| 293 | 293 | } |
| 294 | - if($unreg != null && $unreg) { |
|
| 294 | + if ($unreg != null && $unreg) { |
|
| 295 | 295 | return redirect()->back()->with('success', 'Artikel dihapus !'); |
| 296 | 296 | } |
| 297 | 297 | |