laravel-admin
laravel-admin copied to clipboard
自定义批量上传按钮时,js报错$(...).fileinput is not a function
版本是最新
class ImportEnglish extends Action
{
protected $selector = '.import-english';
public function handle(Request $request)
{
$res = Excel::import(new EnglishImport(), $request->file('file'));
if ($res['code'] != 0) {
return $this->response()->error($res['message']);
}
return $this->response()->success('上传成功')->refresh();
}
public function form()
{
$this->file('file', '请选择文件')->required()->help('表头: [编号],年级,[一级分类],[二级分类],[三级分类],原文,翻译,类型');
}
public function html()
{
return <<<HTML
<a class="btn btn-sm btn-default import-english">导入数据</a>
HTML;
}
}
$grid->tools(function (Grid\Tools $tools) {
$tools->append(new ImportEnglish());
});