Category : maatwebsite-excel

I am performing Excel file upload using PHP-7.4, Laravel-8 and Maatwebsite-3.1 package. Import: public function onRow(Row $row) { $rowIndex = $row->getIndex(); if($rowIndex >= 1000) $row = $row->toArray(); $employee = Employee::create([ ‘first_name’ => $row[0], ‘other_name’ => $row[1] ?? ”, ‘last_name’ => $row[2], ’email’ => preg_replace(‘/s+/’, ”, strtolower($row[3])), ]); } public function startRow(): int { return 2; ..

Read more

I am new on developing application, but now I’m handling a laravel project (website app) that have been deployed on cpanel. Now, I need to use a specific function, but for using it, I need to install the package (the package is maatwebsite/excel). The steps are written here: https://5balloons.info/laravel-export-and-import-excel-using-maatwebsite-package/ (and many other website), but on ..

Read more

I’ve built a system with Laravel&GraphQL and using JWT for authentication. On the front-end, I run Vue.js. So, I need to export tasks in excel format. I use Maatwebsite/Excel for that. Here are my codes for excel export; ExportController.php public function tasks_excel() { return Excel::download(new TasksExport(), ‘tasks.xlsx’); } TasksExport.php (I created this with php artisan ..

Read more

turns out I use this to import an excel file to my table, with laravel public function model(array $row) { ++$this->numRows; return new Alumno([ ‘folio’ => $row[‘folio’], ‘nombre’ => $row[‘nombre’], ‘paterno’ => $row[‘paterno’], ‘cantidad’ => $row[‘cantidad’], ‘materno’ => $row[‘materno’], ‘fecha_nacimiento’ => PhpOfficePhpSpreadsheetSharedDate::excelToDateTimeObject($row[‘fecha_nacimiento’]), ’email’ => $row[’email’], ‘telefono’ => $row[‘telefono’] ]); How could I create my update ..

Read more

I’m trying to create product upload using excel file using maatwebsite in laravel I have written This code for data import if($request->hasFile(‘file’)) { Excel::import(new FoodImport, request()->file(‘file’)); } I also define use AppModelsFoodImport; use Excel; still it gives me error Class ‘AppModelsFoodImport’ not found Can anyone help what I’m missing !? Is there anything i need ..

Read more

I am using Laravel-8 and Maatwebsite-3.1 package for Excel Upload: public function onRow(Row $row) { $rowIndex = $row->getIndex(); if($rowIndex >= 1000) return; // Not more than 1000 rows at a time $row = $row->toArray(); $employee = Employee::create([ ‘first_name’ => $row[0], ‘other_name’ => $row[1] ?? ”, ‘last_name’ => $row[2], ’email’ => preg_replace(‘/s+/’, ”, strtolower($row[3])),, ‘company_id’ => ..

Read more

this my code cause the trouble, $cust = Customer::where(‘name’, ‘=’, $data[$i][0][‘customer_name’])->pluck(‘customer_id’)[0]; this one for get customer id when i do store to sales order $sales = array( ‘customer_id’ => Customer::where(‘name’, ‘=’, $data[$i][0][‘customer_name’])->pluck(‘customer_id’)[0], ‘logistics_id’ => Logistic::where(‘logistics_name’, ‘=’, $data[$i][0][‘logistics’])->pluck(‘logistics_id’)[0], ‘subtotal’ => $data[$i][0][‘subtotal_rp’], ‘shipping_cost’ => $data[$i][0][‘shipping_cost_rp’], ‘discount_code’ => 0, ‘date_of_sales’ => $data[$i][0][‘date’], ‘grand_total’ => $data[$i][0][‘grand_total_rp’], ‘tax’ => $data[$i][0][‘tax_rp’], ..

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

In laravel, I found : View, but I am not able to understand it completely. <?php namespace AppExports; use AppModelsUser; use IlluminateContractsViewView; use MaatwebsiteExcelConcernsFromView; class Export implements FromView { /** * @return IlluminateSupportView */ public function view(): View { return User::all(); } } If someone can explain, then highly appreciated. Sourc..

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 am using Laravel-8 and Maatwebsite-3.1 package for excel upload: I have this Excel sheet (The data is more thank that): imports: use IlluminateValidationRule; use MaatwebsiteExcelRow; use MaatwebsiteExcelConcernsOnEachRow; use MaatwebsiteExcelConcernsWithHeadingRow; use MaatwebsiteExcelConcernsImportable; use MaatwebsiteExcelConcernsWithStartRow; use MaatwebsiteExcelConcernsWithCustomValueBinder; use MaatwebsiteExcelDefaultValueBinder; use PhpOfficePhpSpreadsheetCellCell; use PhpOfficePhpSpreadsheetCellDataType; use MaatwebsiteExcelConcernsWithValidation; use MaatwebsiteExcelConcernsSkipsErrors; use MaatwebsiteExcelConcernsSkipsOnError; use MaatwebsiteExcelConcernsSkipsFailures; use MaatwebsiteExcelConcernsSkipsOnFailure; use IlluminateSupportFacadesValidator; use ..

Read more

I am using Laravel-8 and Maatwebsite-3.1 package for excel upload: imports: public function onRow(Row $row) { $rowIndex = $row->getIndex(); if($rowIndex >= 1000) return; // Not more than 1000 rows at a time $row = $row->toArray(); $employee_data = [ ‘first_name’ => $row[0], ‘other_name’ => $row[1] ?? ”, ‘last_name’ => $row[2], ’email’ => preg_replace(‘/s+/’, ”, strtolower($row[3])), ‘dob’ ..

Read more

How to display a validation message if name field is duplicate in the uploaded file? <?php namespace AppImports; use AppModelsCustomer; use IlluminateSupportCollection; use MaatwebsiteExcelConcernsToCollection; use MaatwebsiteExcelConcernsWithHeadingRow; use MaatwebsiteExcelConcernsWithValidation; class CustomerImport implements ToCollection, WithHeadingRow, WithValidation { public $timestamps = false; public function collection(Collection $rows) { foreach ($rows as $row) { Customer::create([ ‘name’ => $row[‘name’], ‘address’ => ..

Read more

i’m using maatwebsite in laravel. but i dont know how to foreach in maatwebsite. here is may code: public function headings(): array { $mapel = DB::table(‘tb_mapel’)->pluck(‘kode_mapel’)->toArray(); array_unshift($mapel, ‘NIS’, ‘Nama Siswa’); return [ [‘LEGER’], [”, ”, ‘KI3 (Pengetahuan)’], $mapel, [”,”,’nilai’,’predikat’], ]; } here is the result: this is the example what i want in the example ..

Read more

I am using Laravel-8 and Maatwebsite-3.1 package for upload: I have this Excel sheet: class StateOriginImport implements ToModel, WithHeadingRow, WithStartRow, SkipsOnError, WithValidation, SkipsOnFailure { private $countries; use Importable, SkipsErrors, SkipsFailures; public function __construct() { $this->countries = Country::select(‘id’, ‘name’, ‘nationality’)->get(); } public function model(array $row) { $country = $this->countries->where(‘name’, $row[1])->where(‘nationality’, $row[1])->first(); return new StateOrigin([ ‘country_id’ => ..

Read more

i want to ask about how to implement multiple heading in maatwebsite here is may code public function headings(): array { $mapel = DB::table(‘tb_mapel’)->select(‘nama_mapel’)->get()->toArray(); return [ [‘LEGER’], [”, ”, ‘KI3 (Pengetahuan)’], [‘NIS’, ‘Nama Siswa’, $mapel], ]; } this is the the result of code: And this is what i want Sourc..

Read more