<?php

namespace Rhino\Http\Controllers;

use Rhino\Models\Student;
use Illuminate\Http\Request;

class StudentController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return 'Student Controller';
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $persons = User::select('name','id')->get();
        return view('students.create', ['persons'=> $persons, ]);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        return Student::create([
          'student_id' => $request->student_id,
          'school_id' => $request->school_id,
          'user_id' => $request->user_id,
          'SKU' => $request->SKU,
          'student_validated' => false
        ]);
    }

    /**
     * Display the specified resource.
     *
     * @param  \Rhino\Student  $student
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        return Student::whereId($id)->with('user')->get();
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \Rhino\Student  $student
     * @return \Illuminate\Http\Response
     */
    public function edit(Student $student)
    {
        return view('students.edit', ['student'=> Student::whereId($id)->with('user')->get()]);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Rhino\Student  $student
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Student $student)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \Rhino\Student  $student
     * @return \Illuminate\Http\Response
     */
    public function destroy(Student $student)
    {
        //
    }
}
