<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Imports\SantrisImport;
use Maatwebsite\Excel\Facades\Excel;

class SantriImportController extends Controller
{
    public function index()
    {
        return view('santris.import');
    }

    public function store(Request $request)
    {
        $request->validate([
            'file' => 'required|mimes:xlsx,csv,xls'
        ]);

        Excel::import(new SantrisImport, $request->file('file'));

        return back()->with('success', 'Data santri berhasil diimport!');
    }
}
