From 232edde8e49299d5c1cf9f560b517f8cca97ad59 Mon Sep 17 00:00:00 2001 From: Jack Goh Date: Thu, 16 Aug 2018 09:40:54 +0800 Subject: [PATCH 01/10] fix unauthorized booking access --- app/Http/Controllers/BookingController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 49aee280..4b3d1705 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -24,12 +24,12 @@ class BookingController extends Controller public function index(){ $user = Auth::user(); $bookings = Booking::select('user_id', 'id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status') - ->where('user_id', Auth::user()->id) ->where('status', '=', '6') ->orwhere('status', '=', '4') ->orwhere('status', '=', '3') ->orwhere('status', '=', '2') ->orwhere('status', '=', '1') + ->where('user_id', Auth::user()->id) ->orderby('updated_at','desc') ->paginate(10); From 7bbe69638c5693980462b2c200e9aaa22eb5a1cf Mon Sep 17 00:00:00 2001 From: Jack Goh Date: Thu, 16 Aug 2018 09:52:40 +0800 Subject: [PATCH 02/10] fix unauthorized booking access --- app/Http/Controllers/BookingController.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 4b3d1705..27c6b625 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -24,12 +24,19 @@ class BookingController extends Controller public function index(){ $user = Auth::user(); $bookings = Booking::select('user_id', 'id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status') - ->where('status', '=', '6') - ->orwhere('status', '=', '4') - ->orwhere('status', '=', '3') - ->orwhere('status', '=', '2') - ->orwhere('status', '=', '1') + // ->where('status', '=', '6') + // ->orwhere('status', '=', '4') + // ->orwhere('status', '=', '3') + // ->orwhere('status', '=', '2') + // ->orwhere('status', '=', '1') ->where('user_id', Auth::user()->id) + ->where(function ($query) { + $query->where('status', '=', '6') + ->orwhere('status', '=', '4') + ->orwhere('status', '=', '3') + ->orwhere('status', '=', '2') + ->orwhere('status', '=', '1'); + }) ->orderby('updated_at','desc') ->paginate(10); From f6bd74ed5ec7599025d7ade130e1cd537def0fe0 Mon Sep 17 00:00:00 2001 From: Jack Goh Date: Thu, 16 Aug 2018 10:12:05 +0800 Subject: [PATCH 03/10] removed unused code --- app/Http/Controllers/BookingController.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 27c6b625..1135da04 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -24,11 +24,6 @@ class BookingController extends Controller public function index(){ $user = Auth::user(); $bookings = Booking::select('user_id', 'id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status') - // ->where('status', '=', '6') - // ->orwhere('status', '=', '4') - // ->orwhere('status', '=', '3') - // ->orwhere('status', '=', '2') - // ->orwhere('status', '=', '1') ->where('user_id', Auth::user()->id) ->where(function ($query) { $query->where('status', '=', '6') @@ -166,14 +161,13 @@ class BookingController extends Controller public function adminIndex(){ $user = Auth::user(); $bookings = Booking::select('user_id', 'id', 'created_at', 'admin_status', 'rate', 'term', 'amount', 'bia', 'verification_status') - - ->where('admin_status', '=', '5') - ->orwhere('admin_status', '=', '4') - ->orwhere('admin_status', '=', '3') - ->orwhere('admin_status', '=', '2') - ->orwhere('admin_status', '=', '1') - ->orderby('updated_at','desc') - ->paginate(10); + ->where('admin_status', '=', '5') + ->orwhere('admin_status', '=', '4') + ->orwhere('admin_status', '=', '3') + ->orwhere('admin_status', '=', '2') + ->orwhere('admin_status', '=', '1') + ->orderby('updated_at','desc') + ->paginate(10); // reformat to fit frontend structure foreach ($bookings as $booking) { From 5bc4f5929d8ee48ae1b5b29fc6885600f8d96344 Mon Sep 17 00:00:00 2001 From: Jack Goh Date: Thu, 16 Aug 2018 10:23:03 +0800 Subject: [PATCH 04/10] removed all notifications code --- .../Controllers/ChinaBankSlipController.php | 8 --- ..._08_16_101635_drop_notifications_table.php | 28 ++++++++ ...8_16_101737_create_notifications_table.php | 35 +++++++++ database/seeds/NotificationSeeder.php | 35 --------- resources/assets/js/components/Navbar.vue | 72 +++++++++---------- routes/api.php | 14 ++-- 6 files changed, 106 insertions(+), 86 deletions(-) create mode 100644 database/migrations/2018_08_16_101635_drop_notifications_table.php create mode 100644 database/migrations/2018_08_16_101737_create_notifications_table.php delete mode 100644 database/seeds/NotificationSeeder.php diff --git a/app/Http/Controllers/ChinaBankSlipController.php b/app/Http/Controllers/ChinaBankSlipController.php index 0ed406ed..e4cc5742 100644 --- a/app/Http/Controllers/ChinaBankSlipController.php +++ b/app/Http/Controllers/ChinaBankSlipController.php @@ -5,7 +5,6 @@ namespace App\Http\Controllers; use App\ChinaBankSlip; use App\Booking; use App\User; -use App\Notification; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; use Validator; @@ -82,13 +81,6 @@ class ChinaBankSlipController extends Controller $booking->admin_status = 6; $booking->save(); - $userNotification = new Notification; - $userNotification->detail = "Your china bankslip for booking " . $booking->id . " is uploaded."; - $userNotification->link = "/booking/" . $booking->id . "/upload-po"; - $userNotification->user_id = $booking->user_id; - $userNotification->save(); - - return response()->json(["message"=> "Success"],200); } diff --git a/database/migrations/2018_08_16_101635_drop_notifications_table.php b/database/migrations/2018_08_16_101635_drop_notifications_table.php new file mode 100644 index 00000000..d0b458c2 --- /dev/null +++ b/database/migrations/2018_08_16_101635_drop_notifications_table.php @@ -0,0 +1,28 @@ +uuid('id')->primary(); + $table->string('type'); + $table->morphs('notifiable'); + $table->text('data'); + $table->timestamp('read_at')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('notifications'); + } +} diff --git a/database/seeds/NotificationSeeder.php b/database/seeds/NotificationSeeder.php deleted file mode 100644 index 316b11ad..00000000 --- a/database/seeds/NotificationSeeder.php +++ /dev/null @@ -1,35 +0,0 @@ -first(); - $admin = User::where("email", "admin@example.com")->first(); - - DB::table('notifications')->insert([ - 'detail' => 'This is an user seeder notification', - 'user_id' => $user->id, - 'link' => '/', - 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), - 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), - ]); - - DB::table('notifications')->insert([ - 'detail' => 'This is an admin seeder notification', - 'user_id' => $admin->id, - 'link' => '/', - 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), - 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), - ]); - } -} diff --git a/resources/assets/js/components/Navbar.vue b/resources/assets/js/components/Navbar.vue index 7f32c3c2..e7d999fe 100644 --- a/resources/assets/js/components/Navbar.vue +++ b/resources/assets/js/components/Navbar.vue @@ -6,7 +6,7 @@