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.
|
|
<?php
namespace App\Providers;
use App\Models\Demand;use App\Models\DemandBidding;use App\Service\SmsService;use App\Traits\DemandTraits;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) { $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,DemandTraits::$polymorphic[$demand->publisher_type]],[$demand->publisher->contact_phone]); } });
Demand::updated(function ($demand) { //如果状态改变了
if($demand->isDirty('bidding_id')) { if(!empty($demand->publisher->contact_phone)) { $sms = new SmsService(); $sms->send('bidding',[$demand->publisher->name,$demand->id,DemandTraits::$polymorphic[$demand->bidding_user_type]],[$demand->biddingUser->contact_phone]); } } }); }}
|