diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index dcc1c17e..dbfe44d2 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -359,8 +359,9 @@ class BookingController extends Controller // $booking->usd_book_cnap = $request->input('usd_book_cnap'); // $booking->usd_book_bank_branch = $request->input('usd_book_bank_branch'); // $booking->verification_status = $request->input('verification_status'); + // return response()->json($booking, 201); $booking->save(); - //return response()->json('error', 400); + // return response()->json('error', 400); return response()->json($booking, 201); } diff --git a/app/Http/Controllers/NotificationController.php b/app/Http/Controllers/NotificationController.php index 00c8e722..7c8aa8a7 100644 --- a/app/Http/Controllers/NotificationController.php +++ b/app/Http/Controllers/NotificationController.php @@ -42,15 +42,16 @@ class NotificationController extends Controller public function getUserMessage() { - $user_all_notification = Notification::Where("user_id",Auth::user()->id)->orderby('updated_at','desc')->get(); - + $user_all_notification = Notification::Where("user_id",Auth::user()->id) + ->orderby('updated_at','desc') + ->paginate(5); + $user_unread_notification = Notification::Where([["user_id",Auth::user()->id],["is_read",0]]) + ->orderby('updated_at','desc') + ->get(); return response()->json([ "message" =>$user_all_notification, - "unread_message" =>Notification::Where([ - ["user_id",Auth::user()->id], - ["is_read",0] - ])->orderby('updated_at','desc')->get() + "unread_message" =>$user_unread_notification ],200); } diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 06915eec..774f9597 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -1,7 +1,7 @@ { - "/js/lang-zh-CN.489521629fd49ac7628e.js": "/js/lang-zh-CN.489521629fd49ac7628e.js", - "/js/lang-es.459dcb868aa54d488979.js": "/js/lang-es.459dcb868aa54d488979.js", - "/js/lang-en.31386792460363b93c17.js": "/js/lang-en.31386792460363b93c17.js", + "/js/lang-zh-CN.c0da3973e52421a8cfe5.js": "/js/lang-zh-CN.c0da3973e52421a8cfe5.js", + "/js/lang-es.f4a1a5b4a30e92527b46.js": "/js/lang-es.f4a1a5b4a30e92527b46.js", + "/js/lang-en.0f790217417404ecc662.js": "/js/lang-en.0f790217417404ecc662.js", "/js/app.js": "/js/app.js", "/css/app.css": "/css/app.css" } \ No newline at end of file diff --git a/resources/assets/js/components/Navbar.vue b/resources/assets/js/components/Navbar.vue index e01004de..aa7ab426 100644 --- a/resources/assets/js/components/Navbar.vue +++ b/resources/assets/js/components/Navbar.vue @@ -21,23 +21,27 @@ - -
- - - - {{item.detail}} - - - {{item.detail}} - -
- - {{item.time_interval}} - -
-
+ + + Load more +
@@ -96,14 +100,15 @@ export default { loadingNotification:false, bellBadge : 0, unread_message_length:0, + url: '/api/notification/user', + pagination: [], }), - computed: mapGetters({ user: 'auth/user' }), mounted(){ - this.getNotification(); + this.getNotification(this.url); }, methods: { async logout(){ @@ -113,15 +118,16 @@ export default { // Redirect to login. this.$router.push({ name: 'login' }); }, - getNotification(){ + getNotification(url){ this.notification = []; this.loadingNotification=true; axios - .get('/api/notification/user/') + .get(url) .then((response) => { this.loadingNotification=false; - this.notification = response.data; - this.bellBadge = this.notification.unread_message.length; + this.notification = response.data.message.data; + this.bellBadge = response.data.unread_message.length; + this.makePagination(response.data.message); console.log(response.data); }).catch((error) => { console.log(error) @@ -130,11 +136,40 @@ 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; + }, + fetchPaginateBooking(url) { + this.url = url; + this.loadingNotification=true; + if(this.url !== null){ + axios + .get(url) + .then((response) => { + this.loadingNotification=false; + this.notification = this.notification.concat(response.data.message.data); + this.bellBadge = response.data.unread_message.length; + this.makePagination(response.data.message); + console.log(this.notification); + }).catch((error) => { + console.log(error) + this.$router.push({ + name: 'notfound' + }) + }) + } + }, readNotification(notification_id){ axios .post('/api/notification/read-notification/'+notification_id) .then((response) => { - this.getNotification(); + this.getNotification(this.url); }).catch((error) => { console.log(error) this.$router.push({ @@ -156,9 +191,19 @@ export default { margin: -.375rem 0; } .el-dropdown-menu{ - max-height: 50%; + height: 50%; +} +#notification{ overflow-y: scroll; overflow-x: hidden; + max-height: 100%; +} +#notification-load-more{ + position: absolute; + width: 100%; + min-height: 20px; + background: white; + border: 1px solid #dcdfe6; } .el-dropdown-menu__item { line-height: 26px; diff --git a/resources/assets/js/pages/admin/home.vue b/resources/assets/js/pages/admin/home.vue index a595a717..167a4daf 100644 --- a/resources/assets/js/pages/admin/home.vue +++ b/resources/assets/js/pages/admin/home.vue @@ -81,7 +81,6 @@ export default { axios.get(this.url).then(response => { this.bookingTable = response.data.data; $this.makePagination(this.bookingTable); - console.log(response.data.data); }) }, RefreshBooking() { @@ -106,7 +105,6 @@ export default { prev_page_url: data.prev_page_url } this.pagination = pagination - console.log(this.pagination) }, fetchPaginateBooking(url) { this.url = url diff --git a/resources/assets/js/pages/home.vue b/resources/assets/js/pages/home.vue index 1cfab181..3d0e0ba9 100644 --- a/resources/assets/js/pages/home.vue +++ b/resources/assets/js/pages/home.vue @@ -609,6 +609,7 @@ export default { } axios.post('api/booking', newBooking) .then((response) => { + console.log(response); this.loading = false // push with return id this.$router.push({