2 months ago

Error in Data Import from Excel in Laravel 6?

Posted 2 months ago by sumitgroup

I am getting error when i am Importing data from Excel Sheet, I am doing it by Controller. and I am getting this error Call to undefined method Maatwebsite\Excel\Excel::load()

Please let me know if it can be possible by Model,....

Here are my Model..

      namespace App;
      use Illuminate\Database\Eloquent\Model;
      class Lead extends Model
protected $primaryKey = 'lId';

Here are my Controller Code...

 public function import(Request $request){
    $this->validate($request, [
        'select_file' => 'required|mimes:xls, xlsx'
    if($data->count() > 0)
        foreach ($data->toArray() as $key => $value) 
            foreach($valuse as $row)
                    'Follow up Date'=>$row['followup'],
                    'Lead Source'=>$row['lead_source'],
                    'Email Id'=>$row['email'],
                    'Phone Number'=>$row['number'],
    return back()->with('success', 'Excel Data Imported successfully.');

and here are my view code...

<form action="{{ route('import') }}" method="POST" enctype="multipart/form-data">
								<input type="file" name="select_file" class="form-control">
								<input type="submit" name="upload" class="btn btn-primary" value="Upload">

Here are my routes..

    Route::post('lead/import', '[email protected]')->name('import');

Please sign in or create an account to participate in this conversation.