SMK_Kelulusan/app/Console/Commands/ImportExcel.php
2019-05-14 14:58:06 +07:00

49 lines
935 B
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Imports\HasilBelajarsImport;
use Maatwebsite\Excel\Facades\Excel;
class ImportExcel extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ba:import-excel {filename}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Import excel file to table';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
try {
Excel::import(new HasilBelajarsImport, $this->argument('filename'));
} catch (\Exception $e) {
echo $e->getMessage();
}
}
}