<?php

namespace App\Modules\Invoices;

use Illuminate\Http\Request;
use App\Http\Controllers\BaseController;

class InvoiceItemControllerREST extends BaseController
{
    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */
    public function create($sale_id)
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @return Response
     */
    public function store()
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     *
     * @return Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     *
     * @return Response
     */
    public function edit($sale_id, $id)
    {
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  int  $id
     *
     * @return Response
     */
    public function update(Request $request, $invoice_id, $id)
    {
        $item = InvoiceItem::find($id);

        // Mass update the item
        $item->fill($request->except('invoice_id', 'stock_id'));
        $item->save();

        // Touch the invoice
        $item->invoice->save();

        return response()->json([
            'success' => true,
            'data'    => $item->toArray(),
        ]);
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     *
     * @return Response
     */
    public function destroy($id)
    {
        //
    }
}
