<?php

namespace App\Http\Controllers\tatausaha;
use Illuminate\Support\Facades\Response;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Pendaftar;
use App\Models\AsalSekolah;
use Session;
use Input as Input;

class DaftarCtrl extends Controller
{
    public function index()
    {

          $pendaftar = Pendaftar::all();
          return view('tatausaha.Daftar.index',['pendaftar'=>$pendaftar]);
        
    }

    public function editItem(Request $req)
    {
        $this->validate($req,[
            'status'=>'required'
        ]);

        $pen = Pendaftar::find($req->id);
        $pen -> status = $req ->status;
        $pen->save();

        return response()->json($pen);

    }
    
    

    public function destroy($id)
    {
        Pendaftar::destroy($id);

        Session::flash('flash_message', 'Pendaftar deleted!');

        return redirect()->route('Daftar.index')->with('alert-success','Data deleted');
    }


}
