diff --git a/app/Booking.php b/app/Booking.php index 0ff1679f..f0decadf 100644 --- a/app/Booking.php +++ b/app/Booking.php @@ -100,19 +100,6 @@ class Booking extends Model return $this->hasOne(Invoice::class); } - public static function boot() { - parent::boot(); - self::deleting(function($booking) { - $booking->userBankSlip()->delete(); - $booking->supplierBooking()->delete(); - $booking->chinaBankSlip()->each(function($bankslip) { - $bankslip->delete(); - }); - $booking->purchaseOrder()->delete(); - $booking->invoice()->delete(); - }); - } - } diff --git a/app/Notifications/UploadPo.php b/app/Notifications/UploadPo.php new file mode 100644 index 00000000..5af7073c --- /dev/null +++ b/app/Notifications/UploadPo.php @@ -0,0 +1,41 @@ +booking = $booking; + } + + + /** + * Build the mail representation of the notification. + * + * @param mixed $notifiable + * @return \Illuminate\Notifications\Messages\MailMessage + */ + public function toMail($notifiable) + { + $message = new MailMessage; + $message->line('您好, 订单号 : '.$this->booking->id.' 的人民币汇款已成功。 请在这个网址 http://exchange.cief-malaysia.com/ 登录您的账号,并点击以下按钮,上载PO到系统. 谢谢.') + ->line('The payment to your supplier for the order no: '.$this->booking->id.' has been successful, please login to your account at http://exchange.cief-malaysia.com/ and then click on the button below upload your order\'s po'); + foreach ($this->booking->chinaBankSlip as $bankslip){ + $message->attach(Storage::disk('public')->url($bankslip->china_bank_slip_path)); + } + return $message; + } +} diff --git a/routes/web.php b/routes/web.php index d1d23a25..5cda9e4c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -17,6 +17,13 @@ Route::get('/', 'WelcomeController@index'); Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.request'); Route::post('password/reset', 'Auth\ResetPasswordController@postReset')->name('password.reset'); +Route::get('mail', function () { + $booking = App\Invoice::find(9323); + + return (new App\Notifications\UploadPo($booking)) + ->toMail($booking->user); +}); + Route::get('/po-approval', function(){ $approvedInvoices = InvoiceStatuses::where(function($q) { $q->where('status', 'approve')