Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- class ImportPendapatan extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'import:pendapatan';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'Importing income data source to database';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- try{
- $import = $this->import();
- // buka file excel
- dump($import->current());
- // Delete semua baris data yang sama dengan key dari file excel
- $import->next();
- dump($import->current());
- // validasi field dari excel
- $import->next();
- dump($import->current());
- // insert data pendapatan dari excel ke database
- $import->next();
- dump($import->current());
- }catch(Exception $e){
- Log::debug('message');
- }
- }
- private function import(){
- $delete = DB::delete();
- if ($delete){
- yield "Buka file excel";
- } else {
- throw new Exception("Gagal delete");
- }
- yield "Delete semua baris data yang sama dengan key dari file excel";
- yield "Validasi field dari excel";
- yield "Insert data pendapatan dari excel ke database";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement