@@ -5,8 +5,7 @@ |
||
| 5 | 5 | use App\Http\Controllers\Controller; |
| 6 | 6 | use Illuminate\Foundation\Auth\AuthenticatesUsers; |
| 7 | 7 | |
| 8 | -class LoginController extends Controller |
|
| 9 | -{ |
|
| 8 | +class LoginController extends Controller { |
|
| 10 | 9 | /* |
| 11 | 10 | |-------------------------------------------------------------------------- |
| 12 | 11 | | Login Controller |
@@ -5,8 +5,7 @@ |
||
| 5 | 5 | use App\Http\Controllers\Controller; |
| 6 | 6 | use Illuminate\Foundation\Auth\ResetsPasswords; |
| 7 | 7 | |
| 8 | -class ResetPasswordController extends Controller |
|
| 9 | -{ |
|
| 8 | +class ResetPasswordController extends Controller { |
|
| 10 | 9 | /* |
| 11 | 10 | |-------------------------------------------------------------------------- |
| 12 | 11 | | Password Reset Controller |
@@ -10,8 +10,7 @@ |
||
| 10 | 10 | use App\Articles; |
| 11 | 11 | |
| 12 | 12 | |
| 13 | -class UserController extends Controller |
|
| 14 | -{ |
|
| 13 | +class UserController extends Controller { |
|
| 15 | 14 | /** |
| 16 | 15 | * Create a new controller instance. |
| 17 | 16 | * |
@@ -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; |
@@ -9,8 +9,7 @@ |
||
| 9 | 9 | use Illuminate\Support\Facades\Hash; |
| 10 | 10 | |
| 11 | 11 | |
| 12 | -class DoctorController extends Controller |
|
| 13 | -{ |
|
| 12 | +class DoctorController extends Controller { |
|
| 14 | 13 | /** |
| 15 | 14 | * Display a listing of the resource. |
| 16 | 15 | * |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function index() |
| 19 | 19 | { |
| 20 | - $doctor = Doctor::orderBy('name','asc')->paginate(10); |
|
| 20 | + $doctor = Doctor::orderBy('name', 'asc')->paginate(10); |
|
| 21 | 21 | $data = [ |
| 22 | 22 | 'role' => session('role'), |
| 23 | 23 | 'doctor' => $doctor, |
| 24 | 24 | ]; |
| 25 | - return view('pages.doctor')->with('data',$data); |
|
| 25 | + return view('pages.doctor')->with('data', $data); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function store(Request $request) |
| 47 | 47 | { |
| 48 | - $this->validate($request,[ |
|
| 48 | + $this->validate($request, [ |
|
| 49 | 49 | 'specialty' => 'required', |
| 50 | 50 | 'name' => 'required|min:3|max:50', |
| 51 | 51 | 'license' => 'required|min:3|max:191', |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | $doctor->email = $request->input('email'); |
| 63 | 63 | $doctor->password = Hash::make($request->password); |
| 64 | 64 | |
| 65 | - if($doctor->save()) { |
|
| 66 | - return redirect (route('doctor.index'))->with('success', 'Berhasil Menambahkan Dokter !'); |
|
| 65 | + if ($doctor->save()) { |
|
| 66 | + return redirect(route('doctor.index'))->with('success', 'Berhasil Menambahkan Dokter !'); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - return redirect (route('doctor.index'))->with('failed', 'Gagal menambah dokter !'); |
|
| 69 | + return redirect(route('doctor.index'))->with('failed', 'Gagal menambah dokter !'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -77,18 +77,18 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function show($id) |
| 79 | 79 | { |
| 80 | - $doctor = Doctor::where('specialization_id',$id)->orderBy('name','asc')->paginate(5); |
|
| 80 | + $doctor = Doctor::where('specialization_id', $id)->orderBy('name', 'asc')->paginate(5); |
|
| 81 | 81 | $data = [ |
| 82 | 82 | 'doctor' => $doctor |
| 83 | 83 | ]; |
| 84 | - return view('listDoctor')->with('data',$data); |
|
| 84 | + return view('listDoctor')->with('data', $data); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public function showDoctor($id) |
| 88 | 88 | { |
| 89 | 89 | $doctor = Doctor::find($id); |
| 90 | 90 | |
| 91 | - return view('viewDoctor')->with('doctor',$doctor); |
|
| 91 | + return view('viewDoctor')->with('doctor', $doctor); |
|
| 92 | 92 | } |
| 93 | 93 | /** |
| 94 | 94 | * Show the form for editing the specified resource. |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function update(Request $request, $id) |
| 118 | 118 | { |
| 119 | - $this->validate($request,[ |
|
| 119 | + $this->validate($request, [ |
|
| 120 | 120 | 'name' => 'required|min:3|max:50', |
| 121 | 121 | 'password' => 'required_with:password_confirmation|same:password_confirmation|min:6', |
| 122 | 122 | 'password_confirmation' => 'min:6' |
@@ -126,11 +126,11 @@ discard block |
||
| 126 | 126 | $doctor = Doctor::find($id); |
| 127 | 127 | $doctor->name = $request->input('name'); |
| 128 | 128 | $doctor->password = $pass; |
| 129 | - if($doctor->save()) { |
|
| 130 | - return redirect (route('doctor.index'))->with('success', 'Doktor berhasil di update !'); |
|
| 129 | + if ($doctor->save()) { |
|
| 130 | + return redirect(route('doctor.index'))->with('success', 'Doktor berhasil di update !'); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - return redirect (route('doctor.edit', $id))->with('failed', 'Gagal memperbaharui dokter !'); |
|
| 133 | + return redirect(route('doctor.edit', $id))->with('failed', 'Gagal memperbaharui dokter !'); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // public function showSpecialty() |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $doctor = Doctor::find($id); |
| 150 | 150 | $doctor->delete(); |
| 151 | 151 | |
| 152 | - return redirect (route('doctor.index')); |
|
| 152 | + return redirect(route('doctor.index')); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | } |
@@ -5,8 +5,7 @@ |
||
| 5 | 5 | use App\DoctorDetail; |
| 6 | 6 | use Illuminate\Http\Request; |
| 7 | 7 | |
| 8 | -class DoctorDetailController extends Controller |
|
| 9 | -{ |
|
| 8 | +class DoctorDetailController extends Controller { |
|
| 10 | 9 | /** |
| 11 | 10 | * Display a listing of the resource. |
| 12 | 11 | * |
@@ -9,8 +9,7 @@ discard block |
||
| 9 | 9 | use App\Admin; |
| 10 | 10 | use Illuminate\Support\Facades\Storage; |
| 11 | 11 | |
| 12 | -class AdminController extends Controller |
|
| 13 | -{ |
|
| 12 | +class AdminController extends Controller { |
|
| 14 | 13 | /** |
| 15 | 14 | * AdminController constructor. |
| 16 | 15 | */ |
@@ -243,7 +242,8 @@ discard block |
||
| 243 | 242 | /** |
| 244 | 243 | * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector |
| 245 | 244 | */ |
| 246 | - public function destroy() { |
|
| 245 | + public function destroy() |
|
| 246 | + { |
|
| 247 | 247 | $admin = $this->currentUser(); |
| 248 | 248 | |
| 249 | 249 | if($admin->delete()) { |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | 'role' => session('role'), |
| 48 | 48 | 'admin' => $admin, |
| 49 | 49 | ]; |
| 50 | - return view('pages.admin')->with('data',$data); |
|
| 50 | + return view('pages.admin')->with('data', $data); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $data = [ |
| 61 | 61 | 'role' => session('role') |
| 62 | 62 | ]; |
| 63 | - return view ('pages.ext.add-admin')->with('data',$data); |
|
| 63 | + return view('pages.ext.add-admin')->with('data', $data); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function store(Request $request) |
| 73 | 73 | { |
| 74 | - $this->validate($request,[ |
|
| 74 | + $this->validate($request, [ |
|
| 75 | 75 | 'name' => 'required|min:3|max:50', |
| 76 | 76 | 'email' => 'required|email', |
| 77 | 77 | 'password' => 'required_with:password_confirmation|same:password_confirmation|min:6', |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | $admin->email = $request->input('email'); |
| 84 | 84 | $admin->password = Hash::make($request->input('password')); |
| 85 | 85 | |
| 86 | - if($admin->save()) { |
|
| 87 | - return redirect (route('admin.index'))->with('success', 'Admin berhasil di tambahkan !'); |
|
| 86 | + if ($admin->save()) { |
|
| 87 | + return redirect(route('admin.index'))->with('success', 'Admin berhasil di tambahkan !'); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - return redirect (route('admin.index'))->with('failed', 'Gagal menambah admin !'); |
|
| 90 | + return redirect(route('admin.index'))->with('failed', 'Gagal menambah admin !'); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | |
@@ -145,9 +145,9 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | $img = null; |
| 147 | 147 | |
| 148 | - if($request->hasFile('profile_picture')) { |
|
| 148 | + if ($request->hasFile('profile_picture')) { |
|
| 149 | 149 | |
| 150 | - if( $admin->profile_picture != "user-default.jpg") { |
|
| 150 | + if ($admin->profile_picture != "user-default.jpg") { |
|
| 151 | 151 | Storage::delete('public/user_images/'.$admin->profile_picture); |
| 152 | 152 | } |
| 153 | 153 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | $admin->name = $request->input('name'); |
| 167 | 167 | $admin->email = $request->input('email'); |
| 168 | - if($request->hasFile('profile_picture')) { |
|
| 168 | + if ($request->hasFile('profile_picture')) { |
|
| 169 | 169 | $admin->profile_picture = $img; |
| 170 | 170 | } |
| 171 | 171 | $admin->save(); |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | public function editPass($id) |
| 185 | 185 | { |
| 186 | 186 | $admin = $this->currentUser(); |
| 187 | - if($admin->id == $id) { |
|
| 187 | + if ($admin->id == $id) { |
|
| 188 | 188 | $data = [ |
| 189 | 189 | 'admin' => $admin |
| 190 | 190 | ]; |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | public function updatePass(Request $request, $id) |
| 205 | 205 | { |
| 206 | 206 | $admin = $this->currentUser(); |
| 207 | - if($admin->id == $id) { |
|
| 207 | + if ($admin->id == $id) { |
|
| 208 | 208 | |
| 209 | 209 | $this->validate($request, [ |
| 210 | 210 | 'old_password' => 'required|min:6', |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | 'password_confirmation' => 'required|min:6' |
| 213 | 213 | ]); |
| 214 | 214 | |
| 215 | - if($this->validatePass($request->input('old_password'))) { |
|
| 215 | + if ($this->validatePass($request->input('old_password'))) { |
|
| 216 | 216 | $admin->password = Hash::make($request->input('new_password')); |
| 217 | 217 | $admin->save(); |
| 218 | 218 | |
@@ -232,12 +232,12 @@ discard block |
||
| 232 | 232 | public function removeImage() |
| 233 | 233 | { |
| 234 | 234 | $admin = $this->currentUser(); |
| 235 | - if($admin->profile_picture != "user-default.jpg") { |
|
| 235 | + if ($admin->profile_picture != "user-default.jpg") { |
|
| 236 | 236 | Storage::delete('public/user_images/'.$admin->profile_picture); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | $admin->profile_picture = "user-default.jpg"; |
| 240 | - if($admin->save()) { |
|
| 240 | + if ($admin->save()) { |
|
| 241 | 241 | return redirect(route('admin.profile.edit', $admin->id))->with('success', 'Foto profil berhasil dihapus !'); |
| 242 | 242 | } |
| 243 | 243 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | public function destroy() { |
| 250 | 250 | $admin = $this->currentUser(); |
| 251 | 251 | |
| 252 | - if($admin->delete()) { |
|
| 252 | + if ($admin->delete()) { |
|
| 253 | 253 | |
| 254 | 254 | session()->flush(); |
| 255 | 255 | return redirect(route('admin.login', $admin->id))->with('success', 'Akun berhasil dihapus !'); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | private function validatePass(string $oldPassword) |
| 276 | 276 | { |
| 277 | 277 | $admin = $this->currentUser(); |
| 278 | - if(Hash::check($oldPassword, $admin->password)) { |
|
| 278 | + if (Hash::check($oldPassword, $admin->password)) { |
|
| 279 | 279 | return true; |
| 280 | 280 | } |
| 281 | 281 | |
@@ -4,8 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Illuminate\Foundation\Http\Kernel as HttpKernel; |
| 6 | 6 | |
| 7 | -class Kernel extends HttpKernel |
|
| 8 | -{ |
|
| 7 | +class Kernel extends HttpKernel { |
|
| 9 | 8 | /** |
| 10 | 9 | * The application's global HTTP middleware stack. |
| 11 | 10 | * |
@@ -5,8 +5,7 @@ discard block |
||
| 5 | 5 | use App\Doctor; |
| 6 | 6 | use Illuminate\Database\Eloquent\Model; |
| 7 | 7 | |
| 8 | -class Articles extends Model |
|
| 9 | -{ |
|
| 8 | +class Articles extends Model { |
|
| 10 | 9 | /** |
| 11 | 10 | * @var string |
| 12 | 11 | */ |
@@ -34,7 +33,8 @@ discard block |
||
| 34 | 33 | * @param $id |
| 35 | 34 | * @return array |
| 36 | 35 | */ |
| 37 | - public function writer() { |
|
| 36 | + public function writer() |
|
| 37 | + { |
|
| 38 | 38 | $adminId = $this->getAttributeValue('admin_id'); |
| 39 | 39 | $doctorId = $this->getAttributeValue('doctor_id'); |
| 40 | 40 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function cutStr($str) |
| 59 | 59 | { |
| 60 | - if (strlen($str) > 200){ |
|
| 60 | + if (strlen($str) > 200) { |
|
| 61 | 61 | return substr($str,0,200) . "..."; |
| 62 | 62 | } |
| 63 | 63 | return $str; |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | $adminId = $this->getAttributeValue('admin_id'); |
| 39 | 39 | $doctorId = $this->getAttributeValue('doctor_id'); |
| 40 | 40 | |
| 41 | - $writer = ['role', 'data']; |
|
| 41 | + $writer = [ 'role', 'data' ]; |
|
| 42 | 42 | |
| 43 | - if($adminId != null) { |
|
| 44 | - $writer['role'] = "Admin"; |
|
| 45 | - $writer['data'] = Admin::find($adminId); |
|
| 46 | - } elseif($doctorId != null) { |
|
| 47 | - $writer['role'] = "Dokter"; |
|
| 48 | - $writer['data'] = Doctor::find($doctorId); |
|
| 43 | + if ($adminId != null) { |
|
| 44 | + $writer[ 'role' ] = "Admin"; |
|
| 45 | + $writer[ 'data' ] = Admin::find($adminId); |
|
| 46 | + } elseif ($doctorId != null) { |
|
| 47 | + $writer[ 'role' ] = "Dokter"; |
|
| 48 | + $writer[ 'data' ] = Doctor::find($doctorId); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | return $writer; |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function cutStr($str) |
| 59 | 59 | { |
| 60 | - if (strlen($str) > 200){ |
|
| 61 | - return substr($str,0,200) . "..."; |
|
| 60 | + if (strlen($str) > 200) { |
|
| 61 | + return substr($str, 0, 200)."..."; |
|
| 62 | 62 | } |
| 63 | 63 | return $str; |
| 64 | 64 | } |
@@ -70,11 +70,11 @@ discard block |
||
| 70 | 70 | public function getCat($str) |
| 71 | 71 | { |
| 72 | 72 | switch ($str) { |
| 73 | - case "penyakit": return "Penyakit"; break; |
|
| 73 | + case "penyakit": return "Penyakit"; break; |
|
| 74 | 74 | case "obat": return "Obat - obatan"; break; |
| 75 | - case "hidup-sehat": return "Hidup Sehat"; break; |
|
| 76 | - case "keluarga": return "Keluarga"; break; |
|
| 77 | - case "kesehatan": return "Kesehatan"; break; |
|
| 75 | + case "hidup-sehat": return "Hidup Sehat"; break; |
|
| 76 | + case "keluarga": return "Keluarga"; break; |
|
| 77 | + case "kesehatan": return "Kesehatan"; break; |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function index() |
| 19 | 19 | { |
| 20 | - $articles = Articles::orderBy('category','asc')->paginate(5); |
|
| 20 | + $articles = Articles::orderBy('category', 'asc')->paginate(5); |
|
| 21 | 21 | $data = [ |
| 22 | 22 | 'articles' => $articles |
| 23 | 23 | ]; |
@@ -40,20 +40,20 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function store(Request $request) |
| 42 | 42 | { |
| 43 | - $this->validate($request,[ |
|
| 43 | + $this->validate($request, [ |
|
| 44 | 44 | 'category' => 'required', |
| 45 | 45 | 'title' => 'required', |
| 46 | 46 | 'content' => 'required|min:500', |
| 47 | 47 | 'cover_image' => 'image|nullable|max:3999 ' |
| 48 | 48 | ]); |
| 49 | 49 | |
| 50 | - if($request->hasFile('cover_image')){ |
|
| 50 | + if ($request->hasFile('cover_image')) { |
|
| 51 | 51 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
| 52 | 52 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
| 53 | 53 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
| 54 | 54 | $fileNameToStore = $filename.'_'.time().'.'.$extension; |
| 55 | 55 | $path = $request->file('cover_image')->storeAs('public/cover_images', $fileNameToStore); |
| 56 | - }else { |
|
| 56 | + } else { |
|
| 57 | 57 | $fileNameToStore = 'noimage.jpg'; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -61,15 +61,15 @@ discard block |
||
| 61 | 61 | $article->category = $request->input('category'); |
| 62 | 62 | $article->title = $request->input('title'); |
| 63 | 63 | $article->content = $request->input('content'); |
| 64 | - if(session('guard') == 'admin') { |
|
| 64 | + if (session('guard') == 'admin') { |
|
| 65 | 65 | $article->admin_id = Auth::guard('admin')->user()->id; |
| 66 | 66 | } else { |
| 67 | 67 | $article->doctor_id = Auth::guard('doctor')->user()->id; |
| 68 | 68 | } |
| 69 | 69 | $article->cover_image = $fileNameToStore; |
| 70 | 70 | |
| 71 | - if($article->save()) { |
|
| 72 | - return redirect (route('article.index'))->with('success', 'Artikel baru berhasil ditambahkan !'); |
|
| 71 | + if ($article->save()) { |
|
| 72 | + return redirect(route('article.index'))->with('success', 'Artikel baru berhasil ditambahkan !'); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return redirect(route('article.create'))->with('failed', 'Gagal menambahkan artikel.'); |
@@ -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) { |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | public function update(Request $request, $id) |
| 210 | 210 | { |
| 211 | - $this->validate($request,[ |
|
| 211 | + $this->validate($request, [ |
|
| 212 | 212 | 'category' => 'required', |
| 213 | 213 | 'title' => 'required', |
| 214 | 214 | 'content' => 'required|min:500', |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | ]); |
| 218 | 218 | |
| 219 | - if($request->hasFile('cover_image')){ |
|
| 219 | + if ($request->hasFile('cover_image')) { |
|
| 220 | 220 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
| 221 | 221 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
| 222 | 222 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
@@ -228,15 +228,15 @@ discard block |
||
| 228 | 228 | $article->category = $request->input('category'); |
| 229 | 229 | $article->title = $request->input('title'); |
| 230 | 230 | $article->content = $request->input('content'); |
| 231 | - if($request->hasFile('cover_image')){ |
|
| 231 | + if ($request->hasFile('cover_image')) { |
|
| 232 | 232 | $article->cover_image = $fileNameToStore; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - if($article->save()) { |
|
| 236 | - return redirect (route('article.index'))->with('success', 'Artikel berhasil diubah !'); |
|
| 235 | + if ($article->save()) { |
|
| 236 | + return redirect(route('article.index'))->with('success', 'Artikel berhasil diubah !'); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - return redirect (route('article.edit', $id))->with('failed', 'Gagal mengubah artikel !'); |
|
| 239 | + return redirect(route('article.edit', $id))->with('failed', 'Gagal mengubah artikel !'); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -247,11 +247,11 @@ discard block |
||
| 247 | 247 | { |
| 248 | 248 | $article = Articles::find($id); |
| 249 | 249 | |
| 250 | - if($article->cover_image != 'noimage.jpg'){ |
|
| 250 | + if ($article->cover_image != 'noimage.jpg') { |
|
| 251 | 251 | Storage::delete('public/cover_images/'.$article->cover_image); |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - if($article->delete()) { |
|
| 254 | + if ($article->delete()) { |
|
| 255 | 255 | return redirect()->back()->with('success', 'Artikel dihapus !'); |
| 256 | 256 | } |
| 257 | 257 | |
@@ -10,8 +10,7 @@ discard block |
||
| 10 | 10 | use App\Admin; |
| 11 | 11 | use App\Doctor; |
| 12 | 12 | |
| 13 | -class ArticleController extends Controller |
|
| 14 | -{ |
|
| 13 | +class ArticleController extends Controller { |
|
| 15 | 14 | /** |
| 16 | 15 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
| 17 | 16 | */ |
@@ -47,13 +46,13 @@ discard block |
||
| 47 | 46 | 'cover_image' => 'image|nullable|max:3999 ' |
| 48 | 47 | ]); |
| 49 | 48 | |
| 50 | - if($request->hasFile('cover_image')){ |
|
| 49 | + if($request->hasFile('cover_image')) { |
|
| 51 | 50 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
| 52 | 51 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
| 53 | 52 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
| 54 | 53 | $fileNameToStore = $filename.'_'.time().'.'.$extension; |
| 55 | 54 | $path = $request->file('cover_image')->storeAs('public/cover_images', $fileNameToStore); |
| 56 | - }else { |
|
| 55 | + } else { |
|
| 57 | 56 | $fileNameToStore = 'noimage.jpg'; |
| 58 | 57 | } |
| 59 | 58 | |
@@ -216,7 +215,7 @@ discard block |
||
| 216 | 215 | |
| 217 | 216 | ]); |
| 218 | 217 | |
| 219 | - if($request->hasFile('cover_image')){ |
|
| 218 | + if($request->hasFile('cover_image')) { |
|
| 220 | 219 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
| 221 | 220 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
| 222 | 221 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
@@ -228,7 +227,7 @@ discard block |
||
| 228 | 227 | $article->category = $request->input('category'); |
| 229 | 228 | $article->title = $request->input('title'); |
| 230 | 229 | $article->content = $request->input('content'); |
| 231 | - if($request->hasFile('cover_image')){ |
|
| 230 | + if($request->hasFile('cover_image')) { |
|
| 232 | 231 | $article->cover_image = $fileNameToStore; |
| 233 | 232 | } |
| 234 | 233 | |
@@ -247,7 +246,7 @@ discard block |
||
| 247 | 246 | { |
| 248 | 247 | $article = Articles::find($id); |
| 249 | 248 | |
| 250 | - if($article->cover_image != 'noimage.jpg'){ |
|
| 249 | + if($article->cover_image != 'noimage.jpg') { |
|
| 251 | 250 | Storage::delete('public/cover_images/'.$article->cover_image); |
| 252 | 251 | } |
| 253 | 252 | |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Illuminate\Http\Request; |
| 6 | 6 | use Carbon\Carbon; |
| 7 | -Use Illuminate\Support\Facades\Storage; |
|
| 7 | +use Illuminate\Support\Facades\Storage; |
|
| 8 | 8 | use Illuminate\Support\Facades\Auth; |
| 9 | 9 | use App\Articles; |
| 10 | 10 | use App\Admin; |