@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function city() |
| 36 | 36 | { |
| 37 | - return $this->belongsTo('App\City','city_id'); |
|
| 37 | + return $this->belongsTo('App\City', 'city_id'); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function trimStr($str) |
| 45 | 45 | { |
| 46 | - if(strlen($str) > 10) { |
|
| 46 | + if (strlen($str) > 10) { |
|
| 47 | 47 | return substr($str, 0, 10)."..."; |
| 48 | 48 | } |
| 49 | 49 | return $str; |
@@ -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 | } |
@@ -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 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | $user = null; |
| 33 | 33 | $err = null; |
| 34 | 34 | |
| 35 | - if($provider == 'google') { |
|
| 35 | + if ($provider == 'google') { |
|
| 36 | 36 | $user = Socialite::driver($provider)->stateless()->user(); |
| 37 | 37 | } else { |
| 38 | 38 | $user = Socialite::driver($provider)->user(); |
@@ -40,13 +40,13 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $authUser = $this->findOrCreateUser($user, $provider); |
| 42 | 42 | |
| 43 | - $attempt = Auth::guard('web')->attempt(['email' => $authUser->email, 'password' => $authUser->provider_id]); |
|
| 43 | + $attempt = Auth::guard('web')->attempt([ 'email' => $authUser->email, 'password' => $authUser->provider_id ]); |
|
| 44 | 44 | |
| 45 | 45 | $req = new Request([ |
| 46 | 46 | 'email' => $authUser->email, |
| 47 | 47 | ]); |
| 48 | 48 | |
| 49 | - if($attempt) { |
|
| 49 | + if ($attempt) { |
|
| 50 | 50 | $msg = "Selamat Datang ".$authUser->name." !"; |
| 51 | 51 | return redirect()->intended(route('home'))->with('info', $msg); |
| 52 | 52 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | private function findOrCreateUser($user, $provider) |
| 66 | 66 | { |
| 67 | 67 | $authUser = User::where('email', $user->getEmail())->first(); |
| 68 | - if($authUser) { |
|
| 68 | + if ($authUser) { |
|
| 69 | 69 | return $authUser; |
| 70 | 70 | } |
| 71 | 71 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | private function sendFailedLoginResponse(Request $request) |
| 85 | 85 | { |
| 86 | 86 | throw ValidationException::withMessages([ |
| 87 | - 'email' => [trans('auth.failed')], |
|
| 87 | + 'email' => [ trans('auth.failed') ], |
|
| 88 | 88 | ]); |
| 89 | 89 | |
| 90 | 90 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | public function index() |
| 22 | 22 | { |
| 23 | 23 | $doctors = Doctor::orderBy('created_at', 'desc')->paginate(10); |
| 24 | - if(!$doctors) { |
|
| 24 | + if (!$doctors) { |
|
| 25 | 25 | abort(503); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function store(Request $request) |
| 54 | 54 | { |
| 55 | - $this->validate($request,[ |
|
| 55 | + $this->validate($request, [ |
|
| 56 | 56 | 'specialty' => 'required', |
| 57 | 57 | 'name' => 'required|min:3|max:50', |
| 58 | 58 | 'license' => 'required|min:3|max:191', |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | $doctor->email = $request->input('email'); |
| 70 | 70 | $doctor->password = Hash::make($request->password); |
| 71 | 71 | |
| 72 | - if($doctor->save()) { |
|
| 73 | - return redirect (route('doctor.index'))->with('success', 'Berhasil Menambahkan Dokter !'); |
|
| 72 | + if ($doctor->save()) { |
|
| 73 | + return redirect(route('doctor.index'))->with('success', 'Berhasil Menambahkan Dokter !'); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - return redirect (route('doctor.index'))->with('failed', 'Gagal menambah dokter !'); |
|
| 76 | + return redirect(route('doctor.index'))->with('failed', 'Gagal menambah dokter !'); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -84,20 +84,20 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function show($id) |
| 86 | 86 | { |
| 87 | - $doctor = Doctor::where('specialization_id',$id)->orderBy('name','asc')->paginate(5); |
|
| 88 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
| 87 | + $doctor = Doctor::where('specialization_id', $id)->orderBy('name', 'asc')->paginate(5); |
|
| 88 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
| 89 | 89 | $data = [ |
| 90 | 90 | 'doctor' => $doctor, |
| 91 | 91 | 'location' => $location |
| 92 | 92 | ]; |
| 93 | - return view('listDoctor')->with('data',$data); |
|
| 93 | + return view('listDoctor')->with('data', $data); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | public function showDoctor($id) |
| 97 | 97 | { |
| 98 | 98 | $doctor = Doctor::find($id); |
| 99 | 99 | |
| 100 | - return view('viewDoctor')->with('doctor',$doctor); |
|
| 100 | + return view('viewDoctor')->with('doctor', $doctor); |
|
| 101 | 101 | } |
| 102 | 102 | /** |
| 103 | 103 | * Show the form for editing the specified resource. |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function update(Request $request, $id) |
| 127 | 127 | { |
| 128 | - $this->validate($request,[ |
|
| 128 | + $this->validate($request, [ |
|
| 129 | 129 | 'name' => 'required|min:3|max:50', |
| 130 | 130 | 'password' => 'required_with:password_confirmation|same:password_confirmation|min:6', |
| 131 | 131 | 'password_confirmation' => 'min:6' |
@@ -135,41 +135,41 @@ discard block |
||
| 135 | 135 | $doctor = Doctor::find($id); |
| 136 | 136 | $doctor->name = $request->input('name'); |
| 137 | 137 | $doctor->password = $pass; |
| 138 | - if($doctor->save()) { |
|
| 139 | - return redirect (route('doctor.index'))->with('success', 'Doktor berhasil di update !'); |
|
| 138 | + if ($doctor->save()) { |
|
| 139 | + return redirect(route('doctor.index'))->with('success', 'Doktor berhasil di update !'); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - return redirect (route('doctor.edit', $id))->with('failed', 'Gagal memperbaharui dokter !'); |
|
| 142 | + return redirect(route('doctor.edit', $id))->with('failed', 'Gagal memperbaharui dokter !'); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | public function searchDoctor(Request $request) |
| 146 | 146 | { |
| 147 | - if($request->nama == null AND $request->location != null){ |
|
| 148 | - $doctor = Doctor::where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
|
| 149 | - }elseif ($request->location == null AND $request->nama != null){ |
|
| 150 | - $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->orderBy('name','asc')->paginate(5); |
|
| 151 | - }else{ |
|
| 152 | - $doctor = Doctor::where('name','LIKE','%'.$request->nama.'%')->where('city_id',$request->location)->orderBy('name','asc')->paginate(5); |
|
| 147 | + if ($request->nama == null AND $request->location != null) { |
|
| 148 | + $doctor = Doctor::where('city_id', $request->location)->orderBy('name', 'asc')->paginate(5); |
|
| 149 | + }elseif ($request->location == null AND $request->nama != null) { |
|
| 150 | + $doctor = Doctor::where('name', 'LIKE', '%'.$request->nama.'%')->orderBy('name', 'asc')->paginate(5); |
|
| 151 | + } else { |
|
| 152 | + $doctor = Doctor::where('name', 'LIKE', '%'.$request->nama.'%')->where('city_id', $request->location)->orderBy('name', 'asc')->paginate(5); |
|
| 153 | 153 | } |
| 154 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
| 154 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
| 155 | 155 | $data = [ |
| 156 | 156 | 'doctor' => $doctor, |
| 157 | 157 | 'location' => $location |
| 158 | 158 | ]; |
| 159 | 159 | |
| 160 | - return view('listDoctor')->with('data',$data); |
|
| 160 | + return view('listDoctor')->with('data', $data); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | public function searchByRadio(Request $request) |
| 164 | 164 | { |
| 165 | - $locationId = City::where('name','LIKE','%'.$request->location.'%')->pluck('id','name'); |
|
| 166 | - $doctor = Doctor::where('city_id',$locationId)->orderBy('name','asc')->paginate(5); |
|
| 167 | - $location = City::orderBy('name','asc')->pluck('name','id'); |
|
| 165 | + $locationId = City::where('name', 'LIKE', '%'.$request->location.'%')->pluck('id', 'name'); |
|
| 166 | + $doctor = Doctor::where('city_id', $locationId)->orderBy('name', 'asc')->paginate(5); |
|
| 167 | + $location = City::orderBy('name', 'asc')->pluck('name', 'id'); |
|
| 168 | 168 | $data = [ |
| 169 | 169 | 'doctor'=>$doctor, |
| 170 | 170 | 'location' => $location |
| 171 | 171 | ]; |
| 172 | - return view('listDoctor')->with('data',$data); |
|
| 172 | + return view('listDoctor')->with('data', $data); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $doctor = Doctor::find($id); |
| 184 | 184 | $doctor->delete(); |
| 185 | 185 | |
| 186 | - return redirect (route('doctor.index')); |
|
| 186 | + return redirect(route('doctor.index')); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public function index($id) |
| 23 | 23 | { |
| 24 | 24 | $doctor = $this->currentUser(); |
| 25 | - if($doctor->id != $id) { |
|
| 25 | + if ($doctor->id != $id) { |
|
| 26 | 26 | return redirect()->back()->with('warning', 'Anda tidak berhak mengakses laman tersebut.'); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $thread->answer = $request->input('answer'); |
| 55 | 55 | $thread->status = true; |
| 56 | 56 | |
| 57 | - if($thread->save()) { |
|
| 57 | + if ($thread->save()) { |
|
| 58 | 58 | |
| 59 | 59 | $log = Common::registerLog([ |
| 60 | 60 | 'action' => "menjawab diskusi oleh ", |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function edit($id) |
| 80 | 80 | { |
| 81 | 81 | $thread = Thread::find($id); |
| 82 | - if(!$thread) { |
|
| 82 | + if (!$thread) { |
|
| 83 | 83 | abort(404); |
| 84 | 84 | } |
| 85 | 85 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $thread->answer = $request->input('answer'); |
| 111 | 111 | $thread->status = true; |
| 112 | 112 | |
| 113 | - if($thread->save()) { |
|
| 113 | + if ($thread->save()) { |
|
| 114 | 114 | return redirect(route('doctor.thread.show', $id))->with('success', 'Perubahan jawaban terkirim !'); |
| 115 | 115 | } |
| 116 | 116 | return redirect()->back()->with('failed', 'Gagal mengirim perubahan jawaban.'); |
@@ -125,14 +125,14 @@ discard block |
||
| 125 | 125 | public function destroy($id) |
| 126 | 126 | { |
| 127 | 127 | $thread = Thread::find($id); |
| 128 | - if($thread->doctor_id != $this->currentUser()->id) { |
|
| 128 | + if ($thread->doctor_id != $this->currentUser()->id) { |
|
| 129 | 129 | return redirect()->back()->with('warning', 'Anda tidak berhak menghapus jawaban untuk diskusi tersebut.'); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | $thread->doctor_id = null; |
| 133 | 133 | $thread->answer = null; |
| 134 | 134 | $thread->status = false; |
| 135 | - if($thread->save()) { |
|
| 135 | + if ($thread->save()) { |
|
| 136 | 136 | return redirect()->back()->with('success', 'Jawaban dihapus !'); |
| 137 | 137 | } |
| 138 | 138 | return redirect()->back()->with('failed', 'Gagal mengahapus jawaban.'); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | 'role' => session('role'), |
| 55 | 55 | 'admin' => $admin, |
| 56 | 56 | ]; |
| 57 | - return view('pages.admin')->with('data',$data); |
|
| 57 | + return view('pages.admin')->with('data', $data); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $data = [ |
| 68 | 68 | 'role' => session('role') |
| 69 | 69 | ]; |
| 70 | - return view ('pages.ext.add-admin')->with('data',$data); |
|
| 70 | + return view('pages.ext.add-admin')->with('data', $data); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function store(Request $request) |
| 80 | 80 | { |
| 81 | - $this->validate($request,[ |
|
| 81 | + $this->validate($request, [ |
|
| 82 | 82 | 'name' => 'required|min:3|max:50', |
| 83 | 83 | 'email' => 'required|email', |
| 84 | 84 | 'password' => 'required_with:password_confirmation|same:password_confirmation|min:6', |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | $admin->email = $request->input('email'); |
| 91 | 91 | $admin->password = Hash::make($request->input('password')); |
| 92 | 92 | |
| 93 | - if($admin->save()) { |
|
| 94 | - return redirect (route('admin.index'))->with('success', 'Admin berhasil di tambahkan !'); |
|
| 93 | + if ($admin->save()) { |
|
| 94 | + return redirect(route('admin.index'))->with('success', 'Admin berhasil di tambahkan !'); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - return redirect (route('admin.index'))->with('failed', 'Gagal menambah admin !'); |
|
| 97 | + return redirect(route('admin.index'))->with('failed', 'Gagal menambah admin !'); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | $img = null; |
| 154 | 154 | |
| 155 | - if($request->hasFile('profile_picture')) { |
|
| 155 | + if ($request->hasFile('profile_picture')) { |
|
| 156 | 156 | |
| 157 | - if( $admin->profile_picture != "user-default.jpg") { |
|
| 157 | + if ($admin->profile_picture != "user-default.jpg") { |
|
| 158 | 158 | Storage::delete('public/user_images/'.$admin->profile_picture); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $admin->name = $request->input('name'); |
| 174 | 174 | $admin->email = $request->input('email'); |
| 175 | - if($request->hasFile('profile_picture')) { |
|
| 175 | + if ($request->hasFile('profile_picture')) { |
|
| 176 | 176 | $admin->profile_picture = $img; |
| 177 | 177 | } |
| 178 | 178 | $admin->save(); |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | public function editPass($id) |
| 192 | 192 | { |
| 193 | 193 | $admin = $this->currentUser(); |
| 194 | - if($admin->id == $id) { |
|
| 194 | + if ($admin->id == $id) { |
|
| 195 | 195 | $data = [ |
| 196 | 196 | 'admin' => $admin |
| 197 | 197 | ]; |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | public function updatePass(Request $request, $id) |
| 212 | 212 | { |
| 213 | 213 | $admin = $this->currentUser(); |
| 214 | - if($admin->id == $id) { |
|
| 214 | + if ($admin->id == $id) { |
|
| 215 | 215 | |
| 216 | 216 | $this->validate($request, [ |
| 217 | 217 | 'old_password' => 'required|min:6', |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | 'password_confirmation' => 'required|min:6' |
| 220 | 220 | ]); |
| 221 | 221 | |
| 222 | - if($this->validatePass($request->input('old_password'))) { |
|
| 222 | + if ($this->validatePass($request->input('old_password'))) { |
|
| 223 | 223 | $admin->password = Hash::make($request->input('new_password')); |
| 224 | 224 | $admin->save(); |
| 225 | 225 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | public function log($id) |
| 236 | 236 | { |
| 237 | 237 | $admin = $this->currentUser(); |
| 238 | - if($admin->id == $id) { |
|
| 238 | + if ($admin->id == $id) { |
|
| 239 | 239 | $data = [ |
| 240 | 240 | 'admin' => $admin, |
| 241 | 241 | 'logs' => Log::orderBy('created_at', 'desc')->paginate(10) |
@@ -253,12 +253,12 @@ discard block |
||
| 253 | 253 | public function removeImage() |
| 254 | 254 | { |
| 255 | 255 | $admin = $this->currentUser(); |
| 256 | - if($admin->profile_picture != "user-default.jpg") { |
|
| 256 | + if ($admin->profile_picture != "user-default.jpg") { |
|
| 257 | 257 | Storage::delete('public/user_images/'.$admin->profile_picture); |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | $admin->profile_picture = "user-default.jpg"; |
| 261 | - if($admin->save()) { |
|
| 261 | + if ($admin->save()) { |
|
| 262 | 262 | return redirect(route('admin.profile.edit', $admin->id))->with('success', 'Foto profil berhasil dihapus !'); |
| 263 | 263 | } |
| 264 | 264 | } |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | public function destroy() { |
| 271 | 271 | $admin = $this->currentUser(); |
| 272 | 272 | |
| 273 | - if($admin->delete()) { |
|
| 273 | + if ($admin->delete()) { |
|
| 274 | 274 | |
| 275 | 275 | session()->flush(); |
| 276 | 276 | return redirect(route('admin.login', $admin->id))->with('success', 'Akun berhasil dihapus !'); |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | private function validatePass(string $oldPassword) |
| 297 | 297 | { |
| 298 | 298 | $admin = $this->currentUser(); |
| 299 | - if(Hash::check($oldPassword, $admin->password)) { |
|
| 299 | + if (Hash::check($oldPassword, $admin->password)) { |
|
| 300 | 300 | return true; |
| 301 | 301 | } |
| 302 | 302 | |
@@ -17,22 +17,22 @@ discard block |
||
| 17 | 17 | { |
| 18 | 18 | $log = new Log; |
| 19 | 19 | |
| 20 | - $log->action = $data['action']; |
|
| 21 | - $log->target = $data['target']; |
|
| 22 | - $log->prefix = $data['prefix']; |
|
| 20 | + $log->action = $data[ 'action' ]; |
|
| 21 | + $log->target = $data[ 'target' ]; |
|
| 22 | + $log->prefix = $data[ 'prefix' ]; |
|
| 23 | 23 | |
| 24 | - switch($data['target']) { |
|
| 25 | - case 'thread' : $log->thread_id = $data['target_id']; break; |
|
| 26 | - case 'article' : $log->article_id = $data['target_id']; break; |
|
| 24 | + switch ($data[ 'target' ]) { |
|
| 25 | + case 'thread' : $log->thread_id = $data[ 'target_id' ]; break; |
|
| 26 | + case 'article' : $log->article_id = $data[ 'target_id' ]; break; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - switch ($data['actor']) { |
|
| 30 | - case 'admin' : $log->admin_id = $data['actor_id']; break; |
|
| 31 | - case 'doctor' : $log->doctor_id = $data['actor_id']; break; |
|
| 32 | - case 'user' : $log->user_id = $data['actor_id']; break; |
|
| 29 | + switch ($data[ 'actor' ]) { |
|
| 30 | + case 'admin' : $log->admin_id = $data[ 'actor_id' ]; break; |
|
| 31 | + case 'doctor' : $log->doctor_id = $data[ 'actor_id' ]; break; |
|
| 32 | + case 'user' : $log->user_id = $data[ 'actor_id' ]; break; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if($log->save()) { |
|
| 35 | + if ($log->save()) { |
|
| 36 | 36 | return true; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | $c = count($logs); |
| 46 | 46 | $r = 0; |
| 47 | 47 | foreach ($logs as $log) { |
| 48 | - if($log->delete()) { |
|
| 48 | + if ($log->delete()) { |
|
| 49 | 49 | $r++; |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | - if($c == $r) { |
|
| 52 | + if ($c == $r) { |
|
| 53 | 53 | return true; |
| 54 | 54 | } |
| 55 | 55 | return false; |
@@ -58,10 +58,10 @@ discard block |
||
| 58 | 58 | private static function getLogs($data) |
| 59 | 59 | { |
| 60 | 60 | $logs = null; |
| 61 | - if($data['target'] == 'thread') { |
|
| 62 | - $logs = Log::where('thread_id', $data['target_id'])->get(); |
|
| 63 | - } elseif($data['target'] == 'article') { |
|
| 64 | - $logs = Log::where('article_id', $data['target_id'])->get(); |
|
| 61 | + if ($data[ 'target' ] == 'thread') { |
|
| 62 | + $logs = Log::where('thread_id', $data[ 'target_id' ])->get(); |
|
| 63 | + } elseif ($data[ 'target' ] == 'article') { |
|
| 64 | + $logs = Log::where('article_id', $data[ 'target_id' ])->get(); |
|
| 65 | 65 | } |
| 66 | 66 | return $logs; |
| 67 | 67 | } |
@@ -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; |