请查看绑定。当工作分派时,一种有效,而另一种无效。
<?php
namespace App\Providers;
use App\Jobs\SendCalendarEventDataToZohoJob;
use CristianPontes\ZohoCRMClient\ZohoCRMClient;
use Illuminate\Support\ServiceProvider;
class ZohoEntityProvider extends ServiceProvider{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot(){
//
}
/**
* Register the application services.
*
* @return void
*/
public function register(){
//this fires
$this->app->bind(ZohoCRMClient::class, function(){
return new ZohoCRMClient('Products', env('ZOHO_TOKEN'));
});
//this doesn't
$this->app
->when(SendCalendarEventDataToZohoJob::class)
->needs(ZohoCRMClient::class)
->give(function (){
return new ZohoCRMClient('Products', env('ZOHO_TOKEN'));
});
}
}