Category : laravel-excel

I have some headings at the beginning of the excel file I need if the user changes these headings throw an error to him! my code right now (I’m using a queue to import) class UpdateProducts implements ToCollection, WithHeadingRow, WithValidation, WithChunkReading, ShouldQueue, WithEvents, SkipsEmptyRows { use Importable, RegistersEventListeners; public $merchant; public function __construct($merchant) { $this->merchant ..

Read more

I’m trying to import some data into the Database by uploading an Excel file, so here is my Import Class: public function model(array $row) { $member_id = DB::table(‘members’)->where(‘mbr_national_code’, $row[3])->value(‘mbr_id’); return new ImportExamResult([ ‘candidate_id’ => $row[4], ‘nid’ => $row[3], ‘status’ => 1, ‘member_id’ => $member_id, ‘olympiad_id’ => 2, ‘descriptive_score’ => $row[12], ‘four_choice_score’ => $row[10], ‘total_score’ => ..

Read more

I’m using Maatwebsite package for inserting some data into the Database by uploading an Excel file. So here is my routes: Route::get(‘import-form’, ‘[email protected]’); Route::post(‘import-form’, ‘[email protected]’)->name(‘addcutsom.execution’); And here is my Controller: use AppImportsCustomExamImport; use AppOlympiadOlympiadExamExecution; use Excel; public function importForm() { return view(‘import’); } public function executeImport(Request $request) { Excel::import(new CustomExamImport, $request->file); return "Records are imported"; ..

Read more

How to get heading from different table on export? class Kriteria_Export implements FromCollection, WithMapping, WithHeadings { public function collection() { return Alternatif::all(); } public function map($alternatif) :array { return [ $alternatif->nama_alt, ]; } public function headings(): array { return [ ‘Nama Alternatif’, ]; } } Tabel Alternatif Tabel Kriteria When Export I want like this ..

Read more

I am trying to import an excel sheet in Laravel, hosted in AWS Lambda and I am getting error touch(): Unable to create file /var/task/storage/framework/laravel-excel/laravel-excel-ToQHNqV18ybdHCmqQFJKidLr5dSsWSUe.xlsx because Read-only file system My code to import is Excel::toArray(new ClientCompanyImport, $request->file(‘sales_accounts_sheet’)); Then I tried to mention the disc name as third parameter as Excel::toArray(new ClientCompanyImport, ‘mysheet.xlsx’, ‘s3’); and uploaded ..

Read more

I am trying to export more than 10k data in my excel but it show time out or sometime show not reached. What is the best process to export large amount of data in excel. In the i gave mtycontroller and export code. controller: function excel(){ return (new UsersExport())->download(‘invoices.xlsx’); } in the Export folder UsersExport.php ..

Read more

I’m facing an issue when import data with the excel laravel package. Eg: In my import file have 5 items with 3 item error after use validation I want to skip there items and continue import 2 items remain. currently if in the file have any error it will stop import process. Any solution for ..

Read more

I face problem and make me dizzy, what’s wrong with this code and make my program in trouble This is my error SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘id_subdist’ cannot be null (SQL: insert into transaksi (id_subdist, id_toko, id_dso, id_rso, id_channel, id_outlet, id_produk, qty_pcs, harga, nama_promo, free_goods, total_qty_include_free_goods, disc_total, jumlah, status, updated_at, created_at) values (?, ..

Read more

how do I set the border for the active row only (not using range)? this is what i have tried so far public function registerEvents(): array { return [ AfterSheet::class => function (AfterSheet $event) { $event->sheet->getStyle(‘A1:J1’)->applyFromArray([ ‘font’ => [ ‘bold’ => true ], ‘alignment’ => [ ‘horizontal’ => PhpOfficePhpSpreadsheetStyleAlignment::HORIZONTAL_CENTER, ], ‘borders’ => [ ‘allBorders’ => ..

Read more

I am trying to import data from excel file. when i upload .csv file using livewire it convert to .txt file. here is my modal code for importing file: <x-jet-modal maxWidth="sm" wire:model="showImportDialog"> <form wire:submit.prevent="import" method="POST" enctype="multipart/form-data"> <div> <div class="text-lg">Import Users</div> </div> <div> <input type="file" wire:model="users" name="users" id="users" /> </div> <x-jet-button type="submit">Import</x-jet-button> </form> </x-jet-modal> and this ..

Read more

I’m trying to write an Online Store web crapper that can win the buy box of products at an E-commerce website. So at first I tried calling the data on my DB: public function readData() { $getData = Batch::paginate(‘1’); return view(‘get-data’, [ ‘getData’ => $getData, ‘controller’ => app(‘AppHttpControllersRoboPriceController’), ]); } And then at the view¬†get-data, ..

Read more

I’m using Laravel 8 and I have installed "maatwebsite/excel": "^3.1" and then tried to import some data into the DB with this Import Class: use MaatwebsiteExcelConcernsWithHeadingRow; use AppModelsRoboBatch; use IlluminateSupportArr; class BatchImport implements ToModel,WithHeadingRow{ public function model(array $row) { return new Batch([ ‘product_group’ => Arr::get($row, ‘product_group’), ‘title_product_variety’ => Arr::get($row, ‘title_product_variety’), ‘product_code’ => Arr::get($row, ‘product_code’), ‘variety_code’ ..

Read more

I want to import an Excel file into the Database with Laravel 8 and LaravelExcel. So I have installed this package correctly and created a table like this: public function up() { Schema::create(‘batches’, function (Blueprint $table) { $table->id(‘bat_id’); $table->string(‘product_group’,50)->nullable(); $table->string(‘title_product_variety’,250)->nullable(); $table->integer(‘product_code’)->nullable(); $table->integer(‘variety_code’)->nullable(); $table->integer(‘seller_code’)->nullable(); $table->enum(‘activation’, [‘TRUE’, ‘FALSE’]); $table->tinyInteger(‘send_interval’)->nullable(); $table->integer(‘sell_price’)->nullable(); $table->integer(‘mortal_price’)->nullable(); $table->integer(‘promotion_price’)->nullable(); $table->integer(‘consumable_balance’)->nullable(); $table->tinyInteger(‘reserve’)->nullable(); $table->tinyInteger(‘seller_inventory’)->nullable(); $table->tinyInteger(‘digikala_inventory’)->nullable(); $table->tinyInteger(‘maximum_order_count’)->nullable(); ..

Read more

I’m using Laravel 8 and I have successfully installed Maatwebsite on my project. Now I need to export some data from the DB into an Excel file. So I made an Export class like this: class BatchExport implements FromCollection { public function headings():array{ return [ ‘Id’, ‘product_group’, ‘title_product_variety’, ‘product_code’, ‘variety_code’, ‘seller_code’, ‘activation’, ‘activation’, ‘send_interval’, ‘sell_price’, ..

Read more

I have an import of employees with a unique employee number, the problem I’m facing is when 2 rows have the same number, the import still continues. This is my validation for my employee number. ‘*.employee_number’ => [‘required’, ‘max:50’, ‘unique:employee_information,employee_number,NULL,id,company_id,’.Auth::user()->company_id], Vision of the import file Employee Number| ———————| EMP1 //Accepts ———————| EMP1 //Accepts too The ..

Read more