@@ -19,10 +19,10 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | public function __construct() |
| 21 | 21 | { |
| 22 | - $this->middleware('auth', ['except' => [ |
|
| 22 | + $this->middleware('auth', [ 'except' => [ |
|
| 23 | 23 | 'index', |
| 24 | 24 | 'showArticle' |
| 25 | - ]]); |
|
| 25 | + ] ]); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function index() |
| 33 | 33 | { |
| 34 | - $article = Articles::where('category','penyakit')->orderBy('created_at','desc')->take(3)->get(); |
|
| 34 | + $article = Articles::where('category', 'penyakit')->orderBy('created_at', 'desc')->take(3)->get(); |
|
| 35 | 35 | return view('home')->with('article', $article); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | public function edit($id) |
| 56 | 56 | { |
| 57 | 57 | $user = $this->currentUser(); |
| 58 | - if($user->id == $id) { |
|
| 58 | + if ($user->id == $id) { |
|
| 59 | 59 | $data = [ |
| 60 | 60 | 'user' => $user |
| 61 | 61 | ]; |
| 62 | - return view ('profile-edit')->with('data', $data); |
|
| 62 | + return view('profile-edit')->with('data', $data); |
|
| 63 | 63 | } |
| 64 | 64 | return redirect()->back()->with('warning', 'Anda tidak berhak untuk mengakses laman tersebut.'); |
| 65 | 65 | } |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | public function editPass($id) |
| 73 | 73 | { |
| 74 | 74 | $user = $this->currentUser(); |
| 75 | - if($user->id == $id) { |
|
| 75 | + if ($user->id == $id) { |
|
| 76 | 76 | $data = [ |
| 77 | 77 | 'user' => $user |
| 78 | 78 | ]; |
| 79 | - return view ('profile-password')->with('data', $data); |
|
| 79 | + return view('profile-password')->with('data', $data); |
|
| 80 | 80 | } |
| 81 | 81 | return redirect()->back()->with('warning', 'Anda tidak berhak untuk mengakses laman tersebut.'); |
| 82 | 82 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function update(Request $request, $id) |
| 92 | 92 | { |
| 93 | - $this->validate($request,[ |
|
| 93 | + $this->validate($request, [ |
|
| 94 | 94 | 'name' => 'required|min:3', |
| 95 | 95 | 'email' => 'required|email', |
| 96 | 96 | 'image' => 'image|nullable|max:3999' |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | $img = null; |
| 100 | 100 | $user = $this->currentUser(); |
| 101 | 101 | |
| 102 | - if($request->hasFile('image')) { |
|
| 102 | + if ($request->hasFile('image')) { |
|
| 103 | 103 | |
| 104 | - if( $user->profile_picture != "user-default.jpg" && |
|
| 104 | + if ($user->profile_picture != "user-default.jpg" && |
|
| 105 | 105 | $user->profile_picture != "user-default-male.png" && |
| 106 | 106 | $user->profile_picture != "user-default-female.png") { |
| 107 | 107 | |
@@ -128,14 +128,14 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | |
| 131 | - if($this->currentUser()->id == $id) { |
|
| 131 | + if ($this->currentUser()->id == $id) { |
|
| 132 | 132 | $user->name = $request->input('name'); |
| 133 | 133 | $user->biography = $request->input('bio'); |
| 134 | 134 | $user->gender = $request->input('gender'); |
| 135 | 135 | $user->profile_picture = $img; |
| 136 | 136 | $user->save(); |
| 137 | 137 | |
| 138 | - return redirect (route('user.profile.edit', ['id' => $id]))->with('success', 'Profil berhasil diperbarui !'); |
|
| 138 | + return redirect(route('user.profile.edit', [ 'id' => $id ]))->with('success', 'Profil berhasil diperbarui !'); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | return redirect()->back()->with('warning', 'Anda tidak berhak untuk mengakses laman tersebut.'); |
@@ -157,10 +157,10 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $user = $this->currentUser(); |
| 159 | 159 | |
| 160 | - if($this->validatePass($request->input('old_password'))) { |
|
| 160 | + if ($this->validatePass($request->input('old_password'))) { |
|
| 161 | 161 | $user->password = Hash::make($request->input('new_password')); |
| 162 | 162 | |
| 163 | - if($user->save()) { |
|
| 163 | + if ($user->save()) { |
|
| 164 | 164 | session()->flush(); |
| 165 | 165 | |
| 166 | 166 | return redirect(route('login'))->with('success', 'Password berhasil diubah ! Silahkan login kembali.'); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | public function showArticle($id) |
| 179 | 179 | { |
| 180 | 180 | $article = Articles::find($id); |
| 181 | - return view('viewarticle')->with('article',$article); |
|
| 181 | + return view('viewarticle')->with('article', $article); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | |
@@ -190,23 +190,23 @@ discard block |
||
| 190 | 190 | $user = $this->currentUser(); |
| 191 | 191 | $img = null; |
| 192 | 192 | |
| 193 | - if( $user->profile_picture != "user-default.jpg" && |
|
| 193 | + if ($user->profile_picture != "user-default.jpg" && |
|
| 194 | 194 | $user->profile_picture != "user-default-male.png" && |
| 195 | 195 | $user->profile_picture != "user-default-female.png") { |
| 196 | 196 | |
| 197 | 197 | Storage::delete('public/user_images/'.$user->profile_picture); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if( $user->gender != null && $user->gender == "Laki - laki") { |
|
| 200 | + if ($user->gender != null && $user->gender == "Laki - laki") { |
|
| 201 | 201 | $img = "user-default-male.png"; |
| 202 | - } elseif($user->gender != null && $user->gender == "Perempuan") { |
|
| 202 | + } elseif ($user->gender != null && $user->gender == "Perempuan") { |
|
| 203 | 203 | $img = "user-default-female.png"; |
| 204 | 204 | } else { |
| 205 | 205 | $img = "user-default.jpg"; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | $user->profile_picture = $img; |
| 209 | - if($user->save()) { |
|
| 209 | + if ($user->save()) { |
|
| 210 | 210 | return redirect(route('user.profile.edit', $user->id))->with('success', 'Foto profil dihapus !'); |
| 211 | 211 | } |
| 212 | 212 | } |
@@ -218,14 +218,14 @@ discard block |
||
| 218 | 218 | public function destroy() |
| 219 | 219 | { |
| 220 | 220 | $user = $this->currentUser(); |
| 221 | - if( $user->profile_picture != "user-default.jpg" && |
|
| 221 | + if ($user->profile_picture != "user-default.jpg" && |
|
| 222 | 222 | $user->profile_picture != "user-default-male.png" && |
| 223 | 223 | $user->profile_picture != "user-default-female.png") { |
| 224 | 224 | |
| 225 | 225 | Storage::delete('public/user_images/'.$user->profile_picture); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - if($user->delete()) { |
|
| 228 | + if ($user->delete()) { |
|
| 229 | 229 | session()->flush(); |
| 230 | 230 | return redirect(route('home'))->with('success', 'Akun berhasil dihapus !'); |
| 231 | 231 | } |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | private function validatePass(string $oldPassword) |
| 249 | 249 | { |
| 250 | 250 | $user = $this->currentUser(); |
| 251 | - if(Hash::check($oldPassword, $user->password)) { |
|
| 251 | + if (Hash::check($oldPassword, $user->password)) { |
|
| 252 | 252 | return true; |
| 253 | 253 | } |
| 254 | 254 | return false; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | public function index() |
| 18 | 18 | { |
| 19 | - $articles = Articles::orderBy('category','asc')->paginate(5); |
|
| 19 | + $articles = Articles::orderBy('category', 'asc')->paginate(5); |
|
| 20 | 20 | $data = [ |
| 21 | 21 | 'articles' => $articles |
| 22 | 22 | ]; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function store(Request $request) |
| 41 | 41 | { |
| 42 | - $this->validate($request,[ |
|
| 42 | + $this->validate($request, [ |
|
| 43 | 43 | 'category' => 'required', |
| 44 | 44 | 'title' => 'required', |
| 45 | 45 | 'content' => 'required|min:500', |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | $article->category = $request->input('category'); |
| 50 | 50 | $article->title = $request->input('title'); |
| 51 | 51 | $article->content = $request->input('content'); |
| 52 | - if(session('guard') == 'admin') { |
|
| 52 | + if (session('guard') == 'admin') { |
|
| 53 | 53 | $article->admin_id = Auth::guard('admin')->user()->id; |
| 54 | 54 | } else { |
| 55 | 55 | $article->doctor_id = Auth::guard('doctor')->user()->id; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if($article->save()) { |
|
| 59 | - return redirect (route('article.index'))->with('success', 'Artikel baru berhasil ditambahkan !'); |
|
| 58 | + if ($article->save()) { |
|
| 59 | + return redirect(route('article.index'))->with('success', 'Artikel baru berhasil ditambahkan !'); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | return redirect(route('article.create'))->with('failed', 'Gagal menambahkan artikel.'); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $data = [ |
| 102 | - 'articles' => Articles::where('category', $cat)->orderBy('title','asc')->get(), |
|
| 102 | + 'articles' => Articles::where('category', $cat)->orderBy('title', 'asc')->get(), |
|
| 103 | 103 | 'category' => $category, |
| 104 | 104 | 'cat' => $cat |
| 105 | 105 | ]; |
@@ -130,8 +130,8 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | $data = [ |
| 132 | 132 | 'articles' => Articles::where('category', $cat) |
| 133 | - ->where('title','LIKE',$name.'%') |
|
| 134 | - ->orderBy('title','asc') |
|
| 133 | + ->where('title', 'LIKE', $name.'%') |
|
| 134 | + ->orderBy('title', 'asc') |
|
| 135 | 135 | ->get(), |
| 136 | 136 | 'category' => $category, |
| 137 | 137 | 'cat' => $cat |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | { |
| 145 | 145 | $cari = $request->cari; |
| 146 | 146 | $articles = Articles::where('category', $cat) |
| 147 | - ->where('content','LIKE','%'.$cari.'%') |
|
| 148 | - ->orderBy('title','asc') |
|
| 147 | + ->where('content', 'LIKE', '%'.$cari.'%') |
|
| 148 | + ->orderBy('title', 'asc') |
|
| 149 | 149 | ->get(); |
| 150 | 150 | $category = null; |
| 151 | 151 | switch ($cat) { |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | public function update(Request $request, $id) |
| 197 | 197 | { |
| 198 | - $this->validate($request,[ |
|
| 198 | + $this->validate($request, [ |
|
| 199 | 199 | 'category' => 'required', |
| 200 | 200 | 'title' => 'required', |
| 201 | 201 | 'content' => 'required|min:500', |
@@ -206,11 +206,11 @@ discard block |
||
| 206 | 206 | $article->title = $request->input('title'); |
| 207 | 207 | $article->content = $request->input('content'); |
| 208 | 208 | |
| 209 | - if($article->save()) { |
|
| 210 | - return redirect (route('article.index'))->with('success', 'Artikel berhasil diubah !'); |
|
| 209 | + if ($article->save()) { |
|
| 210 | + return redirect(route('article.index'))->with('success', 'Artikel berhasil diubah !'); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - return redirect (route('article.edit', $id))->with('failed', 'Gagal mengubah artikel !'); |
|
| 213 | + return redirect(route('article.edit', $id))->with('failed', 'Gagal mengubah artikel !'); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | { |
| 222 | 222 | $article = Articles::find($id); |
| 223 | 223 | |
| 224 | - if($article->delete()) { |
|
| 224 | + if ($article->delete()) { |
|
| 225 | 225 | return redirect()->back()->with('success', 'Artikel dihapus !'); |
| 226 | 226 | } |
| 227 | 227 | |