Category : import

I just doing project import excel using laravel. But there is an error when import / upload file excel and for web page can open and work. ErrorException Undefined array key 7 public function model(array $row) { return new Dso([ ‘id_dso’ => $row[1], ‘id_rso’ => $row[2], ‘id_focus’ => $row[3], ‘id_wilayah’ => $row[4], ‘id_grup_wilayah’ => $row[5], ..

Read more

I finally can import excel data into database(although different code from usual imports), but it fails to attach the relationship. Three table: users(1st table), role_user(relationship table), and roles(2nd table) error: Call to a member function roles() on boolean Screenshot of the error UserImport.php use AppUser; use MaatwebsiteExcelConcernsToModel; class UserImport implements ToModel { /** * @param ..

Read more

I was posting on last discussion, may be is no clear my problem. I’m apologize if I was created 2 same discussion And now I will attach all information including all code, I hope it can be fixed soon. and there is few part SiswaController.php, use AppExportsSiswaExport; use AppImportsSiswaImport; use MaatwebsiteExcelFacadesExcel; use AppHttpControllersController; class SiswaController ..

Read more

Is there a way to attach relationship in laravel directly in just one function? For example I had Three Table in Database: users(first table), user_role(relationship table), and roles(second table) In controller, AdminController.php I had this: public function import_student(Request $request) { $user = Auth::user(); $this->validate($request, [ ‘file’ => ‘required|mimes:csv,xls,xlsx’ ]); $file = $request->file(‘file’); $nama_file = rand().$file->getClientOriginalName(); ..

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

I have a weird error when trying to import simple data through laravel excel. Here’s my import code: namespace AppImports; use AppContrato; use AppProvisional; use AppRecibo; use CarbonCarbon; use IlluminateDatabaseEloquentModel; use IlluminateSupportFacadesDB; use MaatwebsiteExcelConcernsToModel; use MaatwebsiteExcelConcernsWithHeadingRow; class RecibosFImport implements ToModel, WithHeadingRow { /** * @param array $row * * @return IlluminateDatabaseEloquentModel|null */ public function model(array ..

Read more

I am importing Excel File using Laravel-8 endpoints and Maatwebsite-3.1 package. The way I did it is that, the Uploaded Excel file will first get to the storage (storage/file_imports/student_imports). Then Laravel pickes it up from there, stores it into the DB table through StudentImport using Maatwebsites. StudentImport: <?php namespace AppImports; use AppModelsUser; use AppModelsStudent; use ..

Read more

Hello everyone here i am having a problem Getting Undefined offset: 1, although array $row is having the values public function model(array $row) { return new Result([ ‘roll’=>$row[0], ‘cname’=>$row[1], ‘mname’=>$row[2], ‘fname’=>$row[3], ‘dob’=>$row[4], ‘school_code’=>$row[5], ‘h1’=>$row[6], ‘h2’=>$row[7], ‘e1’=>$row[8], ‘e2’=>$row[9], ‘sanskrit’=>$row[10], ‘m1’=>$row[11], ‘m2’=>$row[12], ‘s1’=>$row[13], ‘s2’=>$row[14], ‘s3’=>$row[15], ‘sp’=>$row[16], ‘sst1’=>$row[17], ‘sst2’=>$row[18], ‘result’=>$row[19], ‘grace’=>$row[20], ]); } please help me out, i ..

Read more

I import in a mysqlDB with "maatwebsite excel" an Excel file (xslx) deposited in a FTP. public function model(array $row) { //echo $this->transformDate($row[6]); //$data = Carbon::createFromFormat(‘Y-m-d H:m:s’, $row[7])->toDateTimeString(); //echo ‘carbon ‘.Carbon::now().'<br>’; //echo Carbon::parse($row[7]); return new Guida([ ‘targa’ => $row[14], ‘driver’ => $row[10], ‘pickup_date’ => Carbon::instance(PhpOfficePhpSpreadsheetSharedDate::excelToDateTimeObject($row[7])), ‘drop_date’ => Carbon::instance(PhpOfficePhpSpreadsheetSharedDate::excelToDateTimeObject($row[8])) ]); } it works but i have ..

Read more

I have two simple files: app.js section.blade.php I’m trying to export one function to the other. app.js file: export function test(testfile) { return ‘test’; } section.blade.php <script type="module"> import { test } from ‘/js/app.js’; console.log(test); </script> When I do this, I get: Uncaught SyntaxError: The requested module ‘/js/app.js’ does not provide an export named ‘test’ ..

Read more

So I want to update the date using import excel laravel 8 when I import excel the second time. Database : public function up() { Schema::create(‘kunjungan’, function (Blueprint $table) { $table->bigIncrements(‘idkunjungan’); $table->string(‘number’, 255)->nullable()->unique(); $table->date(‘tanggalmulaiop’)->nullable(); $table->string(‘ruangopname’, 255)->nullable(); $table->string(‘description’, 255)->nullable(); $table->string(‘spesialisname’,255)->nullable(); $table->string(‘kelas’,255)->nullable(); $table->timestamps(); }); } Model : protected $table = ‘kunjungan’; protected $primarykey = ‘idkunjungan’; protected $fillable ..

Read more

namespace AppImports; use AppModelsUser; use MaatwebsiteExcelConcernsToModel; use MaatwebsiteExcelConcernsWithHeadingRow; class UsersImport implements ToModel , WithHeadingRow { /** * @param array $row * * @return IlluminateDatabaseEloquentModel|null */ public function model(array $row) { return new User([ ‘name’ => $row[‘name’], ‘e_id’ => $row[‘e_id’], ‘clockin_time’ => $row[‘clockin_time’], ‘clockout_time’ => $row[‘clockout_time’], ‘dialinghours’ => $row[‘dialinghours’], ‘date’ => $row[‘date’], ]); } /* public ..

Read more

i have some issue with my import csv in laravel with package MaatWesbite, how to i update the existing data with the import CSV ?? this is my controller : public function storeData(Request $request) { $this->validate($request, [ ‘file’ => ‘required|mimes:csv,txt’ ]); // $date = new DateTime; $exchange_rate = new ExchangeRate(); if ($request->hasFile(‘file’)) { $file = ..

Read more

I am having an array field status and if value 0 exists then I need to validate another field expert. public function rules(): array { return [ ‘status’ => ‘required|array|in:0,1’, ‘expert’ =>’required_if:status,==,0|array’, ]; } How can I use the withValidator.I get this error in_array() expects parameter 2 to be array, null given public function withValidator($validator) ..

Read more