@@ -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'); |
@@ -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 @@ |
||
| 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 = [ |
@@ -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' => [ |
@@ -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,11 +175,11 @@ 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 | - if($thread->delete() && $this->deleteTopic($thread->id_topic)) { |
|
| 182 | + if ($thread->delete() && $this->deleteTopic($thread->id_topic)) { |
|
| 183 | 183 | return redirect(route('user.profile'))->with('success', 'Ulasan dihapus !'); |
| 184 | 184 | } |
| 185 | 185 | return redirect()->back()->with('failed', 'Gagal menghapus ulasan.'); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | { |
| 204 | 204 | $new = new ThreadTopic; |
| 205 | 205 | $new->topic_name = $topic; |
| 206 | - if($new->save()) { |
|
| 206 | + if ($new->save()) { |
|
| 207 | 207 | return $new; |
| 208 | 208 | } |
| 209 | 209 | return null; |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | private function deleteTopic($id) |
| 219 | 219 | { |
| 220 | 220 | $topic = ThreadTopic::find($id); |
| 221 | - if($topic->delete()) { |
|
| 221 | + if ($topic->delete()) { |
|
| 222 | 222 | return true; |
| 223 | 223 | } |
| 224 | 224 | return false; |
@@ -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' => [ |
@@ -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'); |
@@ -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.'); |
@@ -4,8 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Illuminate\Database\Eloquent\Model; |
| 6 | 6 | |
| 7 | -class Log extends Model |
|
| 8 | -{ |
|
| 7 | +class Log extends Model { |
|
| 9 | 8 | /** |
| 10 | 9 | * @var string |
| 11 | 10 | */ |
@@ -32,35 +31,40 @@ discard block |
||
| 32 | 31 | /** |
| 33 | 32 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
| 34 | 33 | */ |
| 35 | - public function thread() { |
|
| 34 | + public function thread() |
|
| 35 | + { |
|
| 36 | 36 | return $this->belongsTo('App\Thread', 'thread_id'); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
| 41 | 41 | */ |
| 42 | - public function article() { |
|
| 42 | + public function article() |
|
| 43 | + { |
|
| 43 | 44 | return $this->belongsTo('App\Articles', 'article_id'); |
| 44 | 45 | } |
| 45 | 46 | |
| 46 | 47 | /** |
| 47 | 48 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
| 48 | 49 | */ |
| 49 | - public function admin() { |
|
| 50 | + public function admin() |
|
| 51 | + { |
|
| 50 | 52 | return $this->belongsTo('App\Admin', 'admin_id'); |
| 51 | 53 | } |
| 52 | 54 | |
| 53 | 55 | /** |
| 54 | 56 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
| 55 | 57 | */ |
| 56 | - public function doctor() { |
|
| 58 | + public function doctor() |
|
| 59 | + { |
|
| 57 | 60 | return $this->belongsTo('App\Doctor', 'doctor_id'); |
| 58 | 61 | } |
| 59 | 62 | |
| 60 | 63 | /** |
| 61 | 64 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
| 62 | 65 | */ |
| 63 | - public function member() { |
|
| 66 | + public function member() |
|
| 67 | + { |
|
| 64 | 68 | return $this->belongsTo('App\User', 'user_id'); |
| 65 | 69 | } |
| 66 | 70 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function index() |
| 17 | 17 | { |
| 18 | - $articles = Articles::orderBy('category','asc')->paginate(15); |
|
| 18 | + $articles = Articles::orderBy('category', 'asc')->paginate(15); |
|
| 19 | 19 | $data = [ |
| 20 | 20 | 'articles' => $articles |
| 21 | 21 | ]; |
@@ -38,20 +38,20 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function store(Request $request) |
| 40 | 40 | { |
| 41 | - $this->validate($request,[ |
|
| 41 | + $this->validate($request, [ |
|
| 42 | 42 | 'category' => 'required', |
| 43 | 43 | 'title' => 'required', |
| 44 | 44 | 'content' => 'required|min:500', |
| 45 | 45 | 'cover_image' => 'image|nullable|max:3999' |
| 46 | 46 | ]); |
| 47 | 47 | |
| 48 | - if($request->hasFile('cover_image')){ |
|
| 48 | + if ($request->hasFile('cover_image')) { |
|
| 49 | 49 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
| 50 | 50 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
| 51 | 51 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
| 52 | 52 | $fileNameToStore = $filename.'_'.time().'.'.$extension; |
| 53 | 53 | $path = $request->file('cover_image')->storeAs('public/cover_images', $fileNameToStore); |
| 54 | - }else { |
|
| 54 | + } else { |
|
| 55 | 55 | $fileNameToStore = 'noimage.jpg'; |
| 56 | 56 | } |
| 57 | 57 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $article->category = $request->input('category'); |
| 60 | 60 | $article->title = $request->input('title'); |
| 61 | 61 | $article->content = $request->input('content'); |
| 62 | - if(session('guard') == 'admin') { |
|
| 62 | + if (session('guard') == 'admin') { |
|
| 63 | 63 | $article->admin_id = Auth::guard('admin')->user()->id; |
| 64 | 64 | } else { |
| 65 | 65 | $article->doctor_id = Auth::guard('doctor')->user()->id; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $article->cover_image = $fileNameToStore; |
| 68 | 68 | |
| 69 | 69 | $log = null; |
| 70 | - if($article->save()) { |
|
| 70 | + if ($article->save()) { |
|
| 71 | 71 | $log = Common::registerLog([ |
| 72 | 72 | 'action' => "membuat artikel baru.", |
| 73 | 73 | 'target' => 'article', |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | ]); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if($log != null && $log == true) { |
|
| 82 | - return redirect (route(session('guard').'.article.index'))->with('success', 'Artikel baru berhasil ditambahkan !'); |
|
| 81 | + if ($log != null && $log == true) { |
|
| 82 | + return redirect(route(session('guard').'.article.index'))->with('success', 'Artikel baru berhasil ditambahkan !'); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | return redirect(route(session('guard').'.article.create'))->with('failed', 'Gagal menambahkan artikel.'); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | public function show($id) |
| 93 | 93 | { |
| 94 | 94 | $article = Articles::find($id); |
| 95 | - if(!$article) { |
|
| 95 | + if (!$article) { |
|
| 96 | 96 | abort(404); |
| 97 | 97 | } |
| 98 | 98 | return view('pages.ext.view-article')->with('article', $article); |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | $data = [ |
| 128 | - 'articles' => Articles::where('category', $cat)->orderBy('title','asc')->get(), |
|
| 128 | + 'articles' => Articles::where('category', $cat)->orderBy('title', 'asc')->get(), |
|
| 129 | 129 | 'category' => $category, |
| 130 | 130 | 'cat' => $cat |
| 131 | 131 | ]; |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | $data = [ |
| 158 | 158 | 'articles' => Articles::where('category', $cat) |
| 159 | - ->where('title','LIKE',$name.'%') |
|
| 160 | - ->orderBy('title','asc') |
|
| 159 | + ->where('title', 'LIKE', $name.'%') |
|
| 160 | + ->orderBy('title', 'asc') |
|
| 161 | 161 | ->get(), |
| 162 | 162 | 'category' => $category, |
| 163 | 163 | 'cat' => $cat |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | { |
| 171 | 171 | $cari = $request->cari; |
| 172 | 172 | $articles = Articles::where('category', $cat) |
| 173 | - ->where('content','LIKE','%'.$cari.'%') |
|
| 174 | - ->orderBy('title','asc') |
|
| 173 | + ->where('content', 'LIKE', '%'.$cari.'%') |
|
| 174 | + ->orderBy('title', 'asc') |
|
| 175 | 175 | ->get(); |
| 176 | 176 | $category = null; |
| 177 | 177 | switch ($cat) { |
@@ -207,11 +207,11 @@ discard block |
||
| 207 | 207 | public function edit($id) |
| 208 | 208 | { |
| 209 | 209 | $article = Articles::find($id); |
| 210 | - if(!$article) { |
|
| 210 | + if (!$article) { |
|
| 211 | 211 | abort(404); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - if($article->writer()['data']->id != Auth::guard(session('guard'))->user()->id) { |
|
| 214 | + if ($article->writer()[ 'data' ]->id != Auth::guard(session('guard'))->user()->id) { |
|
| 215 | 215 | return redirect(session('guard').'/article')->with('warning', 'Anda tidak berhak untuk mengubah Artikel tersebut.'); |
| 216 | 216 | } |
| 217 | 217 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | public function update(Request $request, $id) |
| 231 | 231 | { |
| 232 | - $this->validate($request,[ |
|
| 232 | + $this->validate($request, [ |
|
| 233 | 233 | 'category' => 'required', |
| 234 | 234 | 'title' => 'required', |
| 235 | 235 | 'content' => 'required|min:500', |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | ]); |
| 239 | 239 | |
| 240 | - if($request->hasFile('cover_image')){ |
|
| 240 | + if ($request->hasFile('cover_image')) { |
|
| 241 | 241 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
| 242 | 242 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
| 243 | 243 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
@@ -249,15 +249,15 @@ discard block |
||
| 249 | 249 | $article->category = $request->input('category'); |
| 250 | 250 | $article->title = $request->input('title'); |
| 251 | 251 | $article->content = $request->input('content'); |
| 252 | - if($request->hasFile('cover_image')){ |
|
| 252 | + if ($request->hasFile('cover_image')) { |
|
| 253 | 253 | $article->cover_image = $fileNameToStore; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if($article->save()) { |
|
| 257 | - return redirect (route(session('guard').'.article.index'))->with('success', 'Artikel berhasil diubah !'); |
|
| 256 | + if ($article->save()) { |
|
| 257 | + return redirect(route(session('guard').'.article.index'))->with('success', 'Artikel berhasil diubah !'); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - return redirect (route(session('guard').'.article.edit', $id))->with('failed', 'Gagal mengubah artikel !'); |
|
| 260 | + return redirect(route(session('guard').'.article.edit', $id))->with('failed', 'Gagal mengubah artikel !'); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -268,11 +268,11 @@ discard block |
||
| 268 | 268 | { |
| 269 | 269 | $article = Articles::find($id); |
| 270 | 270 | |
| 271 | - if($article->cover_image != 'noimage.jpg'){ |
|
| 271 | + if ($article->cover_image != 'noimage.jpg') { |
|
| 272 | 272 | Storage::delete('public/cover_images/'.$article->cover_image); |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - if($article->delete()) { |
|
| 275 | + if ($article->delete()) { |
|
| 276 | 276 | return redirect()->back()->with('success', 'Artikel dihapus !'); |
| 277 | 277 | } |
| 278 | 278 | |
@@ -8,8 +8,7 @@ discard block |
||
| 8 | 8 | use Illuminate\Support\Facades\Auth; |
| 9 | 9 | use App\Articles; |
| 10 | 10 | |
| 11 | -class ArticleController extends Controller |
|
| 12 | -{ |
|
| 11 | +class ArticleController extends Controller { |
|
| 13 | 12 | /** |
| 14 | 13 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
| 15 | 14 | */ |
@@ -45,13 +44,13 @@ discard block |
||
| 45 | 44 | 'cover_image' => 'image|nullable|max:3999' |
| 46 | 45 | ]); |
| 47 | 46 | |
| 48 | - if($request->hasFile('cover_image')){ |
|
| 47 | + if($request->hasFile('cover_image')) { |
|
| 49 | 48 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
| 50 | 49 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
| 51 | 50 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
| 52 | 51 | $fileNameToStore = $filename.'_'.time().'.'.$extension; |
| 53 | 52 | $path = $request->file('cover_image')->storeAs('public/cover_images', $fileNameToStore); |
| 54 | - }else { |
|
| 53 | + } else { |
|
| 55 | 54 | $fileNameToStore = 'noimage.jpg'; |
| 56 | 55 | } |
| 57 | 56 | |
@@ -237,7 +236,7 @@ discard block |
||
| 237 | 236 | |
| 238 | 237 | ]); |
| 239 | 238 | |
| 240 | - if($request->hasFile('cover_image')){ |
|
| 239 | + if($request->hasFile('cover_image')) { |
|
| 241 | 240 | $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); |
| 242 | 241 | $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); |
| 243 | 242 | $extension = $request->file('cover_image')->getClientOriginalExtension(); |
@@ -249,7 +248,7 @@ discard block |
||
| 249 | 248 | $article->category = $request->input('category'); |
| 250 | 249 | $article->title = $request->input('title'); |
| 251 | 250 | $article->content = $request->input('content'); |
| 252 | - if($request->hasFile('cover_image')){ |
|
| 251 | + if($request->hasFile('cover_image')) { |
|
| 253 | 252 | $article->cover_image = $fileNameToStore; |
| 254 | 253 | } |
| 255 | 254 | |
@@ -268,7 +267,7 @@ discard block |
||
| 268 | 267 | { |
| 269 | 268 | $article = Articles::find($id); |
| 270 | 269 | |
| 271 | - if($article->cover_image != 'noimage.jpg'){ |
|
| 270 | + if($article->cover_image != 'noimage.jpg') { |
|
| 272 | 271 | Storage::delete('public/cover_images/'.$article->cover_image); |
| 273 | 272 | } |
| 274 | 273 | |
@@ -284,7 +283,8 @@ discard block |
||
| 284 | 283 | * |
| 285 | 284 | * @return mixed |
| 286 | 285 | */ |
| 287 | - private function currentUser() { |
|
| 286 | + private function currentUser() |
|
| 287 | + { |
|
| 288 | 288 | return Auth::guard(session('guard'))->user(); |
| 289 | 289 | } |
| 290 | 290 | } |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | use App\Common; |
| 6 | 6 | use Illuminate\Http\Request; |
| 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 | |