67 lines
1.7 KiB
PHP
67 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\ProfileCourtship;
|
|
use App\Observers\ProfileCourtshipObserver;
|
|
use App\Models\User;
|
|
use App\Observers\UserObserver;
|
|
use App\Models\Moment;
|
|
use App\Observers\MomentObserver;
|
|
use App\Services\CronService;
|
|
use App\Services\SurveyService;
|
|
use App\Services\UploadService;
|
|
use App\Services\WechatService;
|
|
use App\Services\IMService;
|
|
use App\Repositories\Eloquent\SmsRepository as Sms;
|
|
|
|
use Illuminate\Http\Response;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Bootstrap any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
//
|
|
\Schema::defaultStringLength(191);
|
|
User::observe(UserObserver::class);
|
|
Moment::observe(MomentObserver::class);
|
|
ProfileCourtship::observe(ProfileCourtshipObserver::class);
|
|
|
|
// 动态设置 session domain
|
|
$allowedDomains = ['ufutx.com', 'ufutx.cn'];
|
|
$currentDomain = request()->getHost();
|
|
|
|
if (in_array($currentDomain, $allowedDomains)) {
|
|
config(['session.domain' => $currentDomain]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Register any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
//
|
|
$this->app->singleton('cronservice', function ($app) {
|
|
return new CronService(new Sms($app));
|
|
});
|
|
$this->app->singleton('wechatservice', function ($app) {
|
|
return new WechatService(new Sms($app));
|
|
});
|
|
$this->app->singleton('surveyservice', function () {
|
|
return new SurveyService();
|
|
});
|
|
$this->app->singleton('uploadservice', function () {
|
|
return new UploadService();
|
|
});
|
|
}
|
|
}
|