<?php

namespace App\Http\Controllers\calonsiswa;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Models\Prestasi;
use Input as Input;
use App\User;

class PrestasiController extends Controller
{
    public function index()
    {
        return view('calonsiswa.dashboard');
    }



    public function create()
    {
    	$this->data['title'] = 'Lengkapi Form Data Prestasi';
        return view('calonsiswa.prestasi.create',$this->data);
    }


    public function store(Request $request)
    {
        $this->validate($request,[
            'jenis_prestasi'=>'required',
            'nama_prestasi'=>'required',
            'tahun_prestasi'=>'required',
            'penyelenggara'=>'required'
            
        ]);

       		$id = $request->input('id');
            $input['jenis_prestasi'] = $request->input('jenis_prestasi');
            $input['nama_prestasi'] = $request->input('nama_prestasi');
            $input['tahun_prestasi'] = $request->input('tahun_prestasi');
            $input['penyelenggara'] = $request->input('penyelenggara');
            $input['id_pendaftar'] = $request->user()->pendaftar->id;

           
            Prestasi::create($input);
            return redirect()->route('prestasi.index')->with('info','Selesai mendaftar, Lengkapi Data Asal sekolah Anda!'); 
        
           
     }
    
    

    
    


    public function show($id)
        {            //
            $this->data['periodik'] = Periodik::where('id_pendaftar',$id)->get();
            return view('calonsiswa.periodik.show',$this->data);
        }
}
