Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected $signature = 'import:excelfile';
- protected $description = 'This imports an excel file';
- public function __construct()
- {
- parent::__construct();
- }
- public function handle()
- {
- $file = Flag::where('imported', '=', '0')->orderBy('created_at', 'DESC')->first();
- $file_path = 'public/files/' . $file->file_name;
- Excel::load($file_path, function($reader) {
- $reader->each(function($sheet) {
- foreach($sheet->toArray() as $row) {
- RealState::firstOrCreate($sheet->toArray());
- }
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement