<?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'] = 'Buat 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',
            'jenis_beasiswa'=>'required',
            'tahun_mulai'=>'required',
            'tahun_selesai'=>'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['jenis_beasiswa'] = $request->input('jenis_beasiswa');
            $input['tahun_mulai'] = $request->input('tahun_mulai');
            $input['tahun_selesai'] = $request->input('tahun_selesai');
            $input['id_pendaftar'] = $request->user()->pendaftar->id;

           
            Prestasi::create($input);
            return redirect()->route('prestasi.index')->with('info','Selesai mendaftar'); 
        
           
     }
    
    

    
    


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