香洲二院小程序
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.
mini_xzey/app/Providers/AppServiceProvider.php

69 lines
1.7 KiB

<?php
namespace App\Providers;
use App\Services\HisSoap\Client as HisSoapClient;
use App\Services\HisHttp\Client as HisHttpClient;
use Illuminate\Support\Facades\Route;
use Illuminate\Routing\UrlGenerator;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register(): void
{
$this->cross();
$this->registerHisService();
}
/**
* Bootstrap any application services.
*
* @param UrlGenerator $url
* @return void
*/
public function boot(UrlGenerator $url): void
{
Schema::defaultStringLength(191);
// Route参数表正则绑定
Route::pattern('patient_id', '[a-zA-Z0-9]+');
Route::pattern('serial_no', '[a-zA-Z0-9]+');
// 配置https
if(env('REDIRECT_HTTPS')) {
$url->forceScheme('https');
}
}
/**
* 允许跨域
* @return void
*/
protected function cross(): void
{
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET,PUT,POST,PATCH,DELETE");
header('Access-Control-Allow-Headers:x-requested-with,content-type,Authorization');
}
protected function registerHisService(): void
{
// His平台服务 - soap
$this->app->singleton('HisSoapService', function () {
return new HisSoapClient();
});
// His平台服务 - http
$this->app->singleton('HisHttpService', function () {
return new HisHttpClient();
});
}
}