12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace App\Console\Commands;
- use App\Imports\chatOrder;
- use App\Imports\Docter\DocterInfo;
- use App\Imports\Docter\OrganizationInfo;
- use App\Models\Organization;
- use Illuminate\Console\Command;
- use Maatwebsite\Excel\Facades\Excel;
- class ImportDocter extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'import:importDocter {type} {filepath}';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '医生数据导入';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $type = $this->argument('type');
- $file_path = $this->argument('filepath');
- //路径相对于项目根目录即 /public
- if(empty($type) || empty($file_path)){
- dd('请输入完整参数');
- }
- //医生信息导入
- if($type == 'docter'){
- $this->makeDocter($file_path);
- }
- if($type == 'organization'){
- $this->makeOrganization($file_path);
- }
- }
- //医生模块
- public function makeDocter($file_path)
- {
- $this->imports($file_path);
- }
- public function imports($filePath)
- {
- $filePath = './public/import/' . $filePath . '.xls';
- Excel::import(new DocterInfo(), $filePath);
- }
- //机构模块
- public function makeOrganization($file_path)
- {
- $this->importsOrganization($file_path);
- }
- public function importsOrganization($filePath)
- {
- $filePath = './public/import/' . $filePath . '.xls';
- Excel::import(new OrganizationInfo(), $filePath);
- }
- }
|