海南旅游SAAS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

53 lines
1.3 KiB

<?php
namespace App\Providers;
use App\Models\Demand;
use App\Models\DemandBidding;
use App\Service\SmsService;
use App\Traits\DemandTraits;
use App\Traits\SmsTraits;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\ServiceProvider;
class DemandBiddingServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
DemandBidding::created(function ($order) {
if(env('SMS_SWITCH','') == true){
$demand = Demand::query()->with(['publisher'])->where('id', $order->demand_id)->first();
if (!empty($demand->publisher->contact_phone)) {
$sms = new SmsService();
$sms->send('bidding', [$order->biddingUser->name, $demand->id, SmsTraits::$systeaNameText['agent']], [$demand->publisher->contact_phone]);
}
}
});
Demand::updated(function ($demand) {
//如果状态改变了
if(env('SMS_SWITCH' , '') == true && $demand->isDirty('bidding_id')) {
if(!empty($demand->publisher->contact_phone)) {
$sms = new SmsService();
$sms->send('demand',[$demand->publisher->name,$demand->id,SmsTraits::$systeaNameText['supplier']],[$demand->biddingUser->contact_phone]);
}
}
});
}
}