Update source into github
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Services\Upload;
|
||||
use App\Imports\DomainImport;
|
||||
use App\Repositories\Domain\DomainRepositoryInterface;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class DomainController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
public DomainRepositoryInterface $domainRepository
|
||||
)
|
||||
{
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$domain = $this->domainRepository->filter(
|
||||
[
|
||||
'page' => $request->get('page',1),
|
||||
],
|
||||
['type']
|
||||
);
|
||||
$title = "List All Domain";
|
||||
return view("admin.product.domain.index",compact('domain','title'));
|
||||
}
|
||||
|
||||
//import domain from file excel
|
||||
public function import(Request $request,Upload $upload)
|
||||
{
|
||||
$filePath = $upload->FileUpload($request->file);
|
||||
|
||||
if (! $filePath)
|
||||
{
|
||||
return back()->withErrors("Please choose your file");
|
||||
}
|
||||
Excel::import(new DomainImport, Storage::path($filePath));
|
||||
|
||||
unlink(Storage::path($filePath));
|
||||
|
||||
return back()->with('success','Import data from file success');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user