I am getting Call to undefined method Maatwebsite\Excel\Excel::load() error? not sure what's wrong with it.
controller: https://pastebin.com/WKK1cq6j
<?php
namespace App\Http\Controllers;
use App\Member;
use Excel;
use Illuminate\Http\Request;
class MembersController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('members');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function import(Request $request)
{
if($request->file('imported-file'))
{
$path = $request->file('imported-file')->getRealPath();
$data = Excel::load($path, function($reader) {
})->get();
if(!empty($data) && $data->count())
{
$data = $data->toArray();
for($i=0;$i<count($data);$i++)
{
$dataImported[] = $data[$i];
}
}
Member::insert($dataImported);
}
return back();
}
}
Source: https://appdividend.com/2017/06/12/import-export-data-csv-excel-laravel-5-4/
Any suggestions would be helpful.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire