<?php

namespace App\Admin\Actions\Phone;

use App\Imports\PhoneImport;
use Encore\Admin\Actions\Action;
use Illuminate\Http\Request;

class Import extends Action
{
    protected $selector = '.import-tenant';

    public function handle(Request $request)
    {
        $request->file('file');
        $import = new PhoneImport();
        $import->import($request->file('file'));
        return $this->response()->success('导入完成！')->refresh();

    }

    public function form()
    {
        $this->file('file', '请选择文件');
    }

    public function html()
    {
        return <<<HTML
        <a class="btn btn-sm btn-default import-tenant"><i class="fa fa-upload"></i>导入数据</a>
HTML;
    }
}
