From 81bf3ac585fda00f053602bb44254c27529e6f6e Mon Sep 17 00:00:00 2001 From: weiweitoo Date: Sat, 21 Jul 2018 14:15:42 +0800 Subject: [PATCH 01/14] add migration for notification. update booking confirmation --- .../Controllers/NotificationController.php | 10 +++ app/Notification.php | 10 +++ ...07_21_102920_create_notification_table.php | 37 +++++++++ database/seeds/DatabaseSeeder.php | 1 + database/seeds/NotificationSeeder.php | 33 ++++++++ resources/assets/js/pages/home.vue | 78 ++++++++++++------- vendor/composer/autoload_static.php | 2 + 7 files changed, 141 insertions(+), 30 deletions(-) create mode 100644 app/Http/Controllers/NotificationController.php create mode 100644 app/Notification.php create mode 100644 database/migrations/2018_07_21_102920_create_notification_table.php create mode 100644 database/seeds/NotificationSeeder.php diff --git a/app/Http/Controllers/NotificationController.php b/app/Http/Controllers/NotificationController.php new file mode 100644 index 00000000..7bd130ac --- /dev/null +++ b/app/Http/Controllers/NotificationController.php @@ -0,0 +1,10 @@ +increments('id'); + $table->string('detail'); + $table->unsignedInteger('user_id'); + $table->timestamps(); + + $table->foreign('user_id') + ->references('id')->on('users') + ->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('notifications'); + } +} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index ebc04e05..e0ba98e9 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -28,6 +28,7 @@ class DatabaseSeeder extends Seeder $this->call(SettingActiveBankSeeder::class); $this->call(SettingTaxRateSeeder::class); $this->call(SettingBillingChargeSeeder::class); + $this->call(NotificationSeeder::class); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); } } diff --git a/database/seeds/NotificationSeeder.php b/database/seeds/NotificationSeeder.php new file mode 100644 index 00000000..5e567bf6 --- /dev/null +++ b/database/seeds/NotificationSeeder.php @@ -0,0 +1,33 @@ +first(); + $admin = User::where("email", "admin@example.com")->first(); + + DB::table('notifications')->insert([ + 'detail' => 'This is an user seeder notification', + 'user_id' => $user->id, + '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, + '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/pages/home.vue b/resources/assets/js/pages/home.vue index c159acdf..99e8f9fe 100644 --- a/resources/assets/js/pages/home.vue +++ b/resources/assets/js/pages/home.vue @@ -141,19 +141,19 @@ - +
- + - + - + - @@ -178,25 +178,21 @@ Customer Marking : {{ bookingConfirmTable.marking }} + + Payment for (Order No.) : + {{ bookingConfirmTable.payment_order }} + Payment Method : {{ bookingConfirmTable.payment_method }} - CNY/RMB : - {{ bookingConfirmTable.amount }} + Remarks : + {{ bookingConfirmTable.remark }} - + Service Charge : - RMB {{ bookingConfirmTable.service_charge }} - - - RATE : - {{ bookingConfirmTable.rate }} - - - China Beneficiary Acc : - {{ bookingForm.account_name }} + + CNY/RMB : @@ -235,11 +231,40 @@ - Bank in Amount : + Bank In Amount : RM {{ bookingConfirmTable.bankin_amount }} + + China Beneficiary Acc : + + + + +
+ {{index+1}}) {{ item.account_name }} {{ item.account_num }} +
+
+ + + + + + Bank In Amount : + RM {{ bookingConfirmTable.bankin_amount }} + + + + + + + + CIEF WORLDWIDE SDN. BHD.(1134596-M) +
+ MBB 568603010762 + + @@ -343,13 +368,12 @@ export default { amount: '', rate: '' }, - bookingForm: { - // amount: '', + bookingForm: [{ account_name: '', bank_name: '', bank_branch: '', account_num: '' - }, + }], rules: { amount: [{ required: true, @@ -459,8 +483,6 @@ export default { }) }) }, - - makePagination(data){ let pagination ={ current_page: data.current_page, @@ -511,12 +533,11 @@ export default { this.loading = false console.log(response) this.bookingConfirmTable = response.data; - this.bookingConfirmTable.payment_for = 'Full Payment';//For future purpose? - this.bookingConfirmTable.remark = '';//For future purpose? + this.bookingConfirmTable.payment_for = 'Full Payment';//For future purpose + this.bookingConfirmTable.remark = '';//For future purpose + this.bookingConfirmTable.payment_order = '';//For future purpose this.dialogFormVisible = false this.dialogFormVisible1 = true - console.log(this.bookingConfirmTable); - console.log(this.bookingForm); }) .catch((error) => { this.$message({ @@ -550,8 +571,6 @@ export default { amount: this.booking.amount, term: this.term } - - console.log(newBooking) axios.post('api/booking', newBooking) .then((response) => { this.loading = false @@ -560,7 +579,6 @@ export default { name: 'booking.user.upload', params: {id: response.data.id } }) - // pass variable to another router }) .catch((error) => { diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 4bb9b48a..ac9fa334 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -462,6 +462,7 @@ class ComposerStaticInit0eb1f3eb0d8144627e65b3e93f0783e4 'App\\Http\\Middleware\\VerifyCsrfToken' => __DIR__ . '/../..' . '/app/Http/Middleware/VerifyCsrfToken.php', 'App\\Invoice' => __DIR__ . '/../..' . '/app/Invoice.php', 'App\\Marking' => __DIR__ . '/../..' . '/app/Marking.php', + 'App\\Notification' => __DIR__ . '/../..' . '/app/Notification.php', 'App\\Notifications\\ResetPassword' => __DIR__ . '/../..' . '/app/Notifications/ResetPassword.php', 'App\\OAuthProvider' => __DIR__ . '/../..' . '/app/OAuthProvider.php', 'App\\Permission' => __DIR__ . '/../..' . '/app/Permission.php', @@ -2852,6 +2853,7 @@ class ComposerStaticInit0eb1f3eb0d8144627e65b3e93f0783e4 'Namshi\\JOSE\\Signer\\SecLib\\RSA' => __DIR__ . '/..' . '/namshi/jose/src/Namshi/JOSE/Signer/SecLib/RSA.php', 'Namshi\\JOSE\\Signer\\SignerInterface' => __DIR__ . '/..' . '/namshi/jose/src/Namshi/JOSE/Signer/SignerInterface.php', 'Namshi\\JOSE\\SimpleJWS' => __DIR__ . '/..' . '/namshi/jose/src/Namshi/JOSE/SimpleJWS.php', + 'NotificationSeeder' => __DIR__ . '/../..' . '/database/seeds/NotificationSeeder.php', 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider' => __DIR__ . '/..' . '/nunomaduro/collision/src/Adapters/Laravel/CollisionServiceProvider.php', 'NunoMaduro\\Collision\\Adapters\\Laravel\\ExceptionHandler' => __DIR__ . '/..' . '/nunomaduro/collision/src/Adapters/Laravel/ExceptionHandler.php', 'NunoMaduro\\Collision\\Adapters\\Laravel\\Inspector' => __DIR__ . '/..' . '/nunomaduro/collision/src/Adapters/Laravel/Inspector.php', From ae7bf422dee9dcd0b397a70e86d02ad4b80f8640 Mon Sep 17 00:00:00 2001 From: lonetrinity Date: Tue, 24 Jul 2018 12:30:03 +0800 Subject: [PATCH 02/14] pagination for admin booking table --- resources/assets/js/pages/admin/home.vue | 28 ++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/resources/assets/js/pages/admin/home.vue b/resources/assets/js/pages/admin/home.vue index 501256b5..4f0b1f93 100644 --- a/resources/assets/js/pages/admin/home.vue +++ b/resources/assets/js/pages/admin/home.vue @@ -47,6 +47,15 @@
+
+ + Previous + + Page {{pagination.current_page}} of {{pagination.last_page}} + + Next + +
@@ -59,9 +68,10 @@ export default { data () { return { status: null, + pagination: [], bookingTable: [ ], - url: 'api/admin/booking', + url: 'api/admin/booking', loading_btn: false, } }, @@ -80,7 +90,7 @@ export default { this.loading_btn = true axios.get(this.url).then(response => { this.loading_btn = false; - this.bookingTable = response.data + this.bookingTable = response.data.data this.$message({ showClose: true, message: 'Booking is updated', @@ -89,6 +99,20 @@ export default { }) }) }, + makePagination(data){ + let pagination ={ + current_page: data.current_page, + last_page: data.last_page, + next_page_url: data.next_page_url, + prev_page_url: data.prev_page_url + } + this.pagination = pagination + console.log(this.pagination) + }, + fetchPaginateBooking(url) { + this.url = url + this.getBooking() + }, filterHandlerStatus (value, row, column) { const status = row.track_status; if(value ==="Success") From 74e602836bbf3d546adf4de326e27890ee87f8f5 Mon Sep 17 00:00:00 2001 From: lonetrinity Date: Tue, 24 Jul 2018 14:10:31 +0800 Subject: [PATCH 03/14] fix pagination for admin booking table --- app/Http/Controllers/BookingController.php | 2 +- resources/assets/js/pages/admin/home.vue | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 05ce2205..6efd7281 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -80,7 +80,7 @@ class BookingController extends Controller $user = Auth::user(); $bookings = Booking::select('user_id', 'id', 'created_at', 'admin_status', 'rate', 'term', 'amount', 'bia', 'verification_status') ->orderby('updated_at','desc') - ->get(); + ->paginate(10); // reformat to fit frontend structure foreach ($bookings as $booking) { diff --git a/resources/assets/js/pages/admin/home.vue b/resources/assets/js/pages/admin/home.vue index 4f0b1f93..e2bbb1d2 100644 --- a/resources/assets/js/pages/admin/home.vue +++ b/resources/assets/js/pages/admin/home.vue @@ -67,11 +67,11 @@ export default { middleware: 'admin', data () { return { - status: null, - pagination: [], - bookingTable: [ - ], + status: null, + prev_page_url: null, + bookingTable: [], url: 'api/admin/booking', + pagination: [], loading_btn: false, } }, @@ -79,10 +79,12 @@ export default { this.getBooking() }, methods: { - getBooking() { + getBooking(){ let $this = this axios.get(this.url).then(response => { - this.bookingTable = response.data + this.bookingTable = response.data.data + $this.makePagination(response.data) + console.log(response) }) }, RefreshBooking() { From 978df88b0af27fee3c4c4de277e3012e36d653bc Mon Sep 17 00:00:00 2001 From: lonetrinity Date: Tue, 24 Jul 2018 14:15:01 +0800 Subject: [PATCH 04/14] fixTWo pagination for admin booking table --- resources/assets/js/pages/admin/home.vue | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/resources/assets/js/pages/admin/home.vue b/resources/assets/js/pages/admin/home.vue index e2bbb1d2..8c689d93 100644 --- a/resources/assets/js/pages/admin/home.vue +++ b/resources/assets/js/pages/admin/home.vue @@ -67,11 +67,10 @@ export default { middleware: 'admin', data () { return { - status: null, - prev_page_url: null, + status: null, bookingTable: [], url: 'api/admin/booking', - pagination: [], + pagination: {prev_page_url: null}, loading_btn: false, } }, From 563c0d42d7ca2bc3574f98a9e8594d73e30c9a95 Mon Sep 17 00:00:00 2001 From: weiweitoo Date: Tue, 24 Jul 2018 17:02:45 +0800 Subject: [PATCH 05/14] Update UI and migration,seeder for notification. --- .../Controllers/NotificationController.php | 52 ++++++++++++- app/Notification.php | 2 +- ...07_21_102920_create_notification_table.php | 2 + database/seeds/NotificationSeeder.php | 2 + resources/assets/js/components/Navbar.vue | 74 +++++++++++++------ routes/api.php | 9 +++ 6 files changed, 114 insertions(+), 27 deletions(-) diff --git a/app/Http/Controllers/NotificationController.php b/app/Http/Controllers/NotificationController.php index 7bd130ac..05b59a46 100644 --- a/app/Http/Controllers/NotificationController.php +++ b/app/Http/Controllers/NotificationController.php @@ -3,8 +3,56 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use App\Notification; +use Illuminate\Support\Facades\DB; +use Auth; class NotificationController extends Controller { - // -} + public function index() + { + return Notification::all(); + } + + public function show(Notification $notification) + { + return $notification; + } + + public function store(Request $request) + { + $notification = Notification::create($request->all()); + + return response()->json($notification, 201); + } + + public function update(Request $request, Notification $notification) + { + $notification->update($request->all()); + + return response()->json($notification, 200); + } + + public function delete(Notification $notification) + { + $notification->delete(); + + return response()->json(null, 204); + } + + public function getUserMessage() + { + return response()->json([ + "message" =>Notification::Where("user_id",Auth::user()->id)->get(), + "unread_message" =>Notification::Where([ + ["user_id",Auth::user()->id], + ["is_read",0] + ])->get() + ],200); + } + + public function readNotification(){ + $affected = DB::table('notifications')->Where('user_id', Auth::user()->id)->update(array('is_read' => 1)); + return response()->json("Read all message", 200); + } +} \ No newline at end of file diff --git a/app/Notification.php b/app/Notification.php index 893ef182..c9acda64 100644 --- a/app/Notification.php +++ b/app/Notification.php @@ -6,5 +6,5 @@ use Illuminate\Database\Eloquent\Model; class Notification extends Model { - protected $fillable = ['detail','user_id']; + protected $fillable = ['detail','user_id','is_read']; } diff --git a/database/migrations/2018_07_21_102920_create_notification_table.php b/database/migrations/2018_07_21_102920_create_notification_table.php index fcf67b87..7e3be228 100644 --- a/database/migrations/2018_07_21_102920_create_notification_table.php +++ b/database/migrations/2018_07_21_102920_create_notification_table.php @@ -16,7 +16,9 @@ class CreateNotificationTable extends Migration Schema::create('notifications', function (Blueprint $table) { $table->increments('id'); $table->string('detail'); + $table->string('link'); $table->unsignedInteger('user_id'); + $table->boolean('is_read')->default(0); $table->timestamps(); $table->foreign('user_id') diff --git a/database/seeds/NotificationSeeder.php b/database/seeds/NotificationSeeder.php index 5e567bf6..ac238997 100644 --- a/database/seeds/NotificationSeeder.php +++ b/database/seeds/NotificationSeeder.php @@ -19,6 +19,7 @@ class NotificationSeeder extends Seeder DB::table('notifications')->insert([ 'detail' => 'This is an user seeder notification', 'user_id' => $user->id, + 'link' => 'http://www.google.com', 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), ]); @@ -26,6 +27,7 @@ class NotificationSeeder extends Seeder DB::table('notifications')->insert([ 'detail' => 'This is an admin seeder notification', 'user_id' => $admin->id, + 'link' => 'http://www.google.com', '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 ccbabb91..464580d7 100644 --- a/resources/assets/js/components/Navbar.vue +++ b/resources/assets/js/components/Navbar.vue @@ -12,30 +12,24 @@