Created
April 1, 2022 04:47
-
-
Save bogordesaincom/ba3b35a7eedaf9aa2aa45f116dadbb15 to your computer and use it in GitHub Desktop.
PurchaseImportController
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Modules\Atom\Http\Controllers\Import; | |
use App\Import\PurchaseItemImport; | |
use Illuminate\Contracts\Support\Renderable; | |
use Illuminate\Http\Request; | |
use Illuminate\Routing\Controller; | |
use Maatwebsite\Excel\Facades\Excel; | |
class AtomImportPurchaseController extends Controller | |
{ | |
/** | |
* Show the form for creating a new resource. | |
* @return Renderable | |
*/ | |
public function create() | |
{ | |
return view('atom::backend.purchase.import'); | |
} | |
/** | |
* Store a newly created resource in storage. | |
* @param Request $request | |
* @return Renderable | |
*/ | |
public function store(Request $request) | |
{ | |
$request->validate([ | |
'file' => 'required|mimes:csv,xls,xlsx' | |
]); | |
$file = $request->file('file'); | |
$nama_file = rand().$file->getClientOriginalName(); | |
$file->move('import_file',$nama_file); | |
$import = new PurchaseItemImport(); | |
$file_new = public_path('import_file/'.$nama_file); | |
$import_file = $import->import($file_new); | |
toast('Berhasil Di Import','success')->autoClose(1500); | |
return redirect()->route('atom_purchase_import'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment