48 lines
948 B
PHP
48 lines
948 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Console\Commands;
|
||
|
|
|
||
|
|
use App\Imports\TestImport;
|
||
|
|
use Illuminate\Console\Command;
|
||
|
|
|
||
|
|
class TestExport extends Command
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* The name and signature of the console command.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected $signature = 'excel:export {name} {--id=}';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The console command description.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected $description = 'Command description';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create a new command instance.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
parent::__construct();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Execute the console command.
|
||
|
|
*
|
||
|
|
* @return mixed
|
||
|
|
*/
|
||
|
|
public function handle()
|
||
|
|
{
|
||
|
|
$path = storage_path('test.xlsx');
|
||
|
|
\Excel::import(new TestImport, $path);
|
||
|
|
$name = $this->argument('name');
|
||
|
|
$id = $this->option('id');
|
||
|
|
\Excel::store(new \App\Exports\TestExport($id), $name, 'public');
|
||
|
|
}
|
||
|
|
}
|