不应静态调用非静态方法 'load'

Non static method 'load' should not be called statically

这是函数,错误在第25行 '$data = Excel::load($path)->get();'说 None-Static méthode 'load' 不应该被静态调用:

function import(Request $request)
    {
        $this->validate($request, [
            'select_file'  => 'required|mimes:xls,xlsx'
           ]);

           $path = $request->file('select_file')->getRealPath();

           $data = Excel::load($path)->get();

           if($data->count() > 0)
           {
            foreach($data->toArray() as $key => $value)
            {
             foreach($value as $row)
             {
              $insert_data[] = array(
               'zi'         =>        $row['zi'],
               'siteId'     =>    $row['siteId'],
               'gsmId'      =>     $row['gsmId'],
               'topoCont'   =>  $row['topoCont'],
               'plannRedr'  => $row['plannRedr'],
               'Country'    =>   $row['country'],
               'dateReal'   =>  $row['dateReal'],
               'semReal'    =>   $row['semReal'],
               'statuts'    =>   $row['country'],
              );
             }
            }

            if(!empty($insert_data))
            {
             DB::table('tbl_customer')->insert($insert_data);
            }
           }
           return back()->with('success', 'Excel Data Imported successfully.');
          }
      }

将此添加到您的控制器中:

use Maatwebsite\Excel\Facades\Excel;