diff --git a/.env-example b/.env-example index 4271cefe..5c17b459 100644 --- a/.env-example +++ b/.env-example @@ -13,11 +13,6 @@ DB_DATABASE=default DB_USERNAME=default DB_PASSWORD=secret -BROADCAST_DRIVER=log -CACHE_DRIVER=file -SESSION_DRIVER=file -SESSION_LIFETIME=120 -QUEUE_DRIVER=sync REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null diff --git a/app/Events/RateUpdated.php b/app/Events/RateUpdated.php new file mode 100644 index 00000000..58f49817 --- /dev/null +++ b/app/Events/RateUpdated.php @@ -0,0 +1,47 @@ +rate = $rate; + } + + /** + * Get the channels the event should broadcast on. + * + * @return \Illuminate\Broadcasting\Channel|array + */ + public function broadcastOn() + { + return new Channel('rate-updated'); + //return new PrivateChannel('rate-updated'); + } + + public function broadcastWith() { + return [ + 'rate' => $this->rate, + ]; + } + +} diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 5cee1457..1ad14f06 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -25,11 +25,13 @@ class BookingController extends Controller $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(function ($query) { + $query->where('status', '=', '6') + ->orwhere('status', '=', '4') + ->orwhere('status', '=', '3') + ->orwhere('status', '=', '2') + ->orwhere('status', '=', '1'); + }) ->orderby('updated_at','desc') ->paginate(10); @@ -159,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) { @@ -469,7 +470,8 @@ class BookingController extends Controller if ($amount >= 10000 && ($term == 'x2_cash' || $term == 'x2_cheque' || $term == 'x2_ba')) { $svcharge = 0; } else { - $svcharge = 20.00; + //$svcharge = 20.00; + $svcharge = 0; // UPDATE ON : 15-8-2018 from PM } $subtotal = round(($amount + $svcharge) / $rate, 2); @@ -638,16 +640,9 @@ class BookingController extends Controller $booking->admin_status = 2; $booking->save(); - // Add notification message to admin - $adminNotification = new Notification; - $adminNotification->detail = "A bankslip is uploaded for booking " . $booking->id; - $adminNotification->link = "/booking/" . $booking->id . "/verification"; - $adminNotification->user_id = User::withRole('admin')->first()->id; - $adminNotification->save(); - $user_bankslip->transfer_amount = $request->input('transfer_amount'); $user_bankslip->save(); - return response()->json($adminNotification,200); + return response()->json(["success"=>true],200); } public function uploadPurchaseOrder(Request $request, $id) @@ -796,7 +791,8 @@ class BookingController extends Controller if ($amount >= 10000 && ($term == 'x2_cash' || $term == 'x2_cheque' || $term == 'x2_ba')) { $svcharge = 0; } else { - $svcharge = 20.00; + //$svcharge = 20.00; + $svcharge = 0; // UPDATE ON : 15-8-2018 from PM } $subtotal = round(($amount + $svcharge) / $rate,2); @@ -868,21 +864,13 @@ class BookingController extends Controller $booking->status = 4; if($booking->term !== "x1_ba" || $booking->term !== "x2_cheque"){ $booking->admin_status = 3; - // Add notification message to user - $userNotification = new Notification; - $userNotification->detail = "Your bankslip for booking " . $booking->id . " is approved."; - $userNotification->link = "/booking/" . $booking->id . "/transfer"; - $userNotification->user_id = $booking->user_id; - $userNotification->save(); + // TODO : Add notification message to user + } else{ $booking->admin_status = 5; - // Add notification message to user - $userNotification = new Notification; - $userNotification->detail = "Your bankslip for booking " . $booking->id . " is approved."; - $userNotification->link = "/booking/" . $booking->id . "/supplier"; - $userNotification->user_id = $booking->user_id; - $userNotification->save(); + // TODO : Add notification message to user + } $booking->save(); @@ -981,11 +969,11 @@ class BookingController extends Controller $booking->admin_status = 5; // upload china bankslip if($booking->save()){ - $userNotification = new Notification; - $userNotification->detail = "Supplier booking report for booking " . $booking->id . " is completed."; - $userNotification->link = "/booking/" . $booking->id . "/transfer"; - $userNotification->user_id = $booking->user_id; - $userNotification->save(); + // $userNotification = new Notification; + // $userNotification->detail = "Supplier booking report for booking " . $booking->id . " is completed."; + // $userNotification->link = "/booking/" . $booking->id . "/transfer"; + // $userNotification->user_id = $booking->user_id; + // $userNotification->save(); return response()->json(['message'=>"Success"],200); } } @@ -1002,12 +990,6 @@ class BookingController extends Controller $booking->admin_status = 6; // upload invoice $booking->save(); - $adminNotification = new Notification; - $adminNotification->detail = "Purchase Order for booking " . $booking->id . " is uploaded."; - $adminNotification->link = "/booking/" . $booking->id . "/upload-invoice"; - $adminNotification->user_id = User::withRole('admin')->first()->id; - $adminNotification->save(); - return response()->json($purchase_order,200); } @@ -1025,11 +1007,6 @@ class BookingController extends Controller $booking->admin_status = 7; // completed if($booking->save()){ - $adminNotification = new Notification; - $adminNotification->detail = "Invoice for booking " . $booking->id . " is uploaded."; - $adminNotification->link = "/booking/" . $booking->id . "/complete"; - $adminNotification->user_id = $booking->user_id; - $adminNotification->save(); return response()->json(['message'=>"Success"],200); } } 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/app/Observers/RateObserver.php b/app/Observers/RateObserver.php new file mode 100644 index 00000000..14e55867 --- /dev/null +++ b/app/Observers/RateObserver.php @@ -0,0 +1,21 @@ + ["auth:api"]]); require base_path('routes/channels.php'); } diff --git a/caddy/Caddyfile b/caddy/Caddyfile index eaf1b056..e4f1b0d1 100644 --- a/caddy/Caddyfile +++ b/caddy/Caddyfile @@ -1,5 +1,4 @@ https://exchange-staging.izyim.com { - proxy /phpmyadmin 127.0.0.1:8090 root /var/www/public fastcgi / 127.0.0.1:9000 php { diff --git a/composer.json b/composer.json index 3ae12a1a..97b020e5 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "laravel/socialite": "^3.0", "laravel/tinker": "~1.0", "laravelcollective/html": "^5.6", + "pusher/pusher-php-server": "~3.0", "tymon/jwt-auth": "^1.0.0-rc.2", "zizaco/entrust": "dev-master" }, diff --git a/config/app.php b/config/app.php index 3d40b81c..1c1d20d4 100644 --- a/config/app.php +++ b/config/app.php @@ -165,7 +165,7 @@ return [ */ App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, - // App\Providers\BroadcastServiceProvider::class, + App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, diff --git a/config/broadcasting.php b/config/broadcasting.php index 5eecd2b2..3ca45eaa 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -36,7 +36,8 @@ return [ 'secret' => env('PUSHER_APP_SECRET'), 'app_id' => env('PUSHER_APP_ID'), 'options' => [ - // + 'cluster' => env('PUSHER_APP_CLUSTER'), + 'encrypted' => true, ], ], diff --git a/database/migrations/2018_08_15_154652_remove_foreight_from_setting_active_banks_table.php b/database/migrations/2018_08_15_154652_remove_foreight_from_setting_active_banks_table.php new file mode 100644 index 00000000..d6ffe132 --- /dev/null +++ b/database/migrations/2018_08_15_154652_remove_foreight_from_setting_active_banks_table.php @@ -0,0 +1,32 @@ +dropForeign('setting_active_banks_beneficiary_id_foreign'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('setting_active_banks', function (Blueprint $table) { + // + }); + } +} 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/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index e0ba98e9..ebc04e05 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -28,7 +28,6 @@ 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 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/package.json b/package.json index 33534d51..1f7f1eff 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,10 @@ "element-ui": "^2.4.4", "jquery": "^3.3.1", "js-cookie": "^2.2.0", + "laravel-echo": "^1.4.0", "npm": "^6.0.1", "popper.js": "^1.14.1", + "pusher-js": "^4.3.0", "sweetalert2": "^7.15.1", "vform": "^1.0.0", "vue": "^2.5.16", diff --git a/resources/assets/js/components/LocaleDropdown.vue b/resources/assets/js/components/LocaleDropdown.vue index 7b490660..0e411ddf 100644 --- a/resources/assets/js/components/LocaleDropdown.vue +++ b/resources/assets/js/components/LocaleDropdown.vue @@ -210,6 +210,7 @@ export default { }) }, + } } diff --git a/resources/assets/js/components/Navbar.vue b/resources/assets/js/components/Navbar.vue index 7f32c3c2..46544951 100644 --- a/resources/assets/js/components/Navbar.vue +++ b/resources/assets/js/components/Navbar.vue @@ -6,7 +6,7 @@