<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\WorkOrderNote;
use Illuminate\Http\Request;

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

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $workOrderNote = new WorkOrderNote();
        $workOrderNote->notetype = $request->input('notetype');
        $workOrderNote->thenote = $request->input('thenote');
        $workOrderNote->noteuser = $request->input('noteuser');
        $workOrderNote->woid = $request->input('woid');
        $workOrderNote->save();
        event(new \App\Events\WorkOrderNoteAdded($workOrderNote));
        return response()->json($workOrderNote, 200);
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\WorkOrderNote  $workOrderNote
     * @return \Illuminate\Http\Response
     */
    public function show(WorkOrderNote $workOrderNote)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\WorkOrderNote  $workOrderNote
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, WorkOrderNote $workOrderNote)
    {
        $workOrderNote->thenote = $request->input('thenote');
        $workOrderNote->save();
        event(new \App\Events\WorkOrderNoteUpdated($workOrderNote));
        return response()->json($workOrderNote, 200);
    }

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