基本的なExcelシートをlaravel 5.1にインポートする方法を学ぼうとしています
vname Vservice vphone vmobile
test name test service test number 123232 test mobile 12344
私は次の機能を作りました
public function ImportVlist()
{
Excel::load('/import.xlsx', function($reader)
{
$results = $reader->get();
foreach ($results as $key => $value) {
foreach ($value as $key => $value1) {
Vlist::create([
'vname'=>$value1->vname,
'vservice' => $value1->vservice,
'vphone' => $value1->vphone,
'vmobile' => $value1->vmobile
]);
}
}
})->get();
}
ルートを作りました
Route::get('/vlist/import' , 'VlistsController@ImportVlist');
インデックスに次のリンクを作成しました
<li><a href="{{ action('VlistsController@ImportVlist') }}"> <span>Import Suppliers </span></a></li>
しかし、クリックすると、Excelの横にページが見つからず、mysql dbにインポートされません