removed all notifications code

This commit is contained in:
Jack Goh
2018-08-16 10:23:03 +08:00
parent e03dc2e562
commit 5bc4f5929d
6 changed files with 106 additions and 86 deletions
@@ -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);
}
@@ -0,0 +1,28 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class DropNotificationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::dropIfExists('notifications');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
@@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateNotificationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->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');
}
}
-35
View File
@@ -1,35 +0,0 @@
<?php
use Illuminate\Database\Seeder;
use App\User;
use Carbon\Carbon;
class NotificationSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$user = User::where("email", "user@example.com")->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'),
]);
}
}
+36 -36
View File
@@ -6,7 +6,7 @@
</router-link>
<template v-if="user">
<el-dropdown trigger="click" align="right">
<!-- <el-dropdown trigger="click" align="right">
<el-badge :value="bellBadge > 0 ? bellBadge : ''" class="item">
<el-button icon="el-icon-bell" circle @click="refreshNoti()"></el-button>
</el-badge>
@@ -32,7 +32,7 @@
<el-button v-if="pagination.next_page_url != null" id="notification-load-more" v-on:click='fetchPaginateBooking(pagination.next_page_url)'>Load more</el-button>
<div v-else id="notification-load-more"></div>
</el-dropdown-menu>
</el-dropdown>
</el-dropdown> -->
</template>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggler" aria-controls="navbarToggler" aria-expanded="false">
@@ -98,8 +98,8 @@ export default {
data: () => ({
appName: window.config.appName,
notification:[],
loadingNotification:false,
//notification:[],
//loadingNotification:false,
bellBadge : 0,
unread_message_length:0,
url: '/api/notification/user',
@@ -110,7 +110,7 @@ export default {
}),
mounted(){
if(this.user){
this.getNotification(this.url)
//this.getNotification(this.url)
}
},
methods: {
@@ -130,24 +130,24 @@ export default {
console.log(response.data);
})
},
getNotification(url){
this.notification = [];
this.loadingNotification=true;
axios
.get(url)
.then((response) => {
this.loadingNotification=false;
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)
this.$router.push({
name: 'notfound'
})
})
},
// getNotification(url){
// this.notification = [];
// this.loadingNotification=true;
// axios
// .get(url)
// .then((response) => {
// this.loadingNotification=false;
// 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)
// this.$router.push({
// name: 'notfound'
// })
// })
// },
makePagination(data){
let pagination ={
current_page: data.current_page,
@@ -159,7 +159,7 @@ export default {
},
fetchPaginateBooking(url) {
this.url = url;
this.loadingNotification=true;
//this.loadingNotification=true;
if(this.url !== null){
axios
.get(url)
@@ -177,18 +177,18 @@ export default {
})
}
},
readNotification(notification_id){
axios
.post('/api/notification/read-notification/'+notification_id)
.then((response) => {
this.getNotification(this.url);
}).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.url);
// }).catch((error) => {
// console.log(error)
// this.$router.push({
// name: 'notfound'
// })
// })
// },
navigateTo(nav) {
window.location.href = nav;
}
+7 -7
View File
@@ -49,8 +49,8 @@ Route::group(['middleware' => 'auth:api'], function () {
Route::patch('settings/profile', 'Settings\ProfileController@update');
Route::patch('settings/password', 'Settings\PasswordController@update');
Route::get('notification/user', 'NotificationController@getUserMessage');
Route::post('notification/read-notification/{notification_id}', 'NotificationController@readNotification');
//Route::get('notification/user', 'NotificationController@getUserMessage');
//Route::post('notification/read-notification/{notification_id}', 'NotificationController@readNotification');
// for both user and admin
Route::get('active-bank', 'SettingActiveBankController@index');
@@ -115,11 +115,11 @@ Route::group(['middleware' => ['role:admin']], function() {
Route::put('supplier-booking/{id}', 'BookingSupplierController@update');
Route::post('booking/{id}/confirm-supplier', 'BookingController@confirmSupplier');
Route::get('notification', 'NotificationController@index');
Route::get('notification/{notification}', 'NotificationController@show');
Route::post('notification', 'NotificationController@store');
Route::put('notification/{notification}', 'NotificationController@update');
Route::delete('notification/{notification}', 'NotificationController@delete');
// Route::get('notification', 'NotificationController@index');
// Route::get('notification/{notification}', 'NotificationController@show');
// Route::post('notification', 'NotificationController@store');
// Route::put('notification/{notification}', 'NotificationController@update');
// Route::delete('notification/{notification}', 'NotificationController@delete');
Route::post('booking/{id}/upload-china-bankslip','ChinaBankSlipController@store');
Route::patch('booking/{id}/update-china-bankslip','ChinaBankSlipController@update');