<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Marking;

class MarkingController extends Controller
{
    public function index()
    {
        return Marking::all();
    }

    public function show(Marking $marking)
    {
        return $marking;
    }

    public function store(Request $request)
    {
        $marking = new Marking; 
        $marking->marking = strtoupper($request->input('marking'));
        $marking->email = $request->input('email');
        $marking->save();
		
        return response()->json($marking, 201);
    }

    public function update(Request $request, Marking $marking)
    {
        // TODO : update to upper case
        $marking->update($request->all());

        return response()->json($marking, 200);
    }

    public function delete(Marking $marking)
    {
        $marking->delete();

        return response()->json(null, 204);
    }
}
