<?php

namespace App\Http\Controllers;

use App\Http\Resources\MachineStatusResource;
use App\Models\machine_status;
use Illuminate\Http\Request;

class MachineStatusController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index()
    {
        return MachineStatusResource::collection(machine_status::all());
    }

    /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(Request $request)
    {
        $machine_status = new machine_status();
        $machine_status->id = $request->id;
        $machine_status->status = $request->status;
        $machine_status->show = $request->show;
        $machine_status->description = $request->description;
        $machine_status->save();
        return response()->json(// todo : see macro vidoes
            [
                "data"=> $machine_status,
                "message"=>"success",
                "status"=>true,
            ]);
    }

    /**
     * Display the specified resource.
     */
    public function show(machine_status $machine_status, $id)
    {
        return response()->json(// todo : see macro vidoes
            [
                "data"=> new MachineStatusResource(machine_status::find($id)),
                "message"=>"success",
                "status"=>true,
            ]);
    }

    /**
     * Show the form for editing the specified resource.
     */
    public function edit(machine_status $machine_status)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     */
    public function update(Request $request, $id)
    {
        $machine_status = machine_status::find($id);
        $machine_status->id = $request->id;
        $machine_status->status = $request->status;
        $machine_status->show = $request->show;
        $machine_status->description = $request->description;
        $machine_status->save();
        return response()->json(// todo : see macro vidoes
            [
                "data"=> $machine_status,
                "message"=>"success",
                "status"=>true,
            ]);
    }

    /**
     * Remove the specified resource from storage.
     */
    public function destroy(machine_status $machine_status)
    {
        //
    }
}
