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