<?php

namespace App\Http\Controllers\Admin\Shop;

use App\Datatables\Admin\Shop\InvoicesDataTable;
use App\Http\Controllers\Controller;
use App\Repositories\Shop\Invoices;
use Illuminate\Http\Request;

class InvoiceController extends Controller
{
    public function index(InvoicesDataTable $dataTable)
    {
        return $dataTable->render('Admin.Shop.Invoices.list');
    }

    public function create()
    {
        return view('Admin.Shop.Invoices.create');
    }

    public function store(Request $request)
    {
        $ret = Invoices::store($request->all());

        return redirect()->route('Admin.Shop.Invoices.index');
    }

    public function show($id)
    {
        $data = [];
        $data['invoice'] = Invoices::getFull($id)->toArray();

        return view('Admin.Shop.Invoices.view', $data);
    }

    public function edit($id)
    {
        $data = Invoices::init();
        $data['invoice'] = Invoices::getFull($id)->toArray();

        return view('Admin.Shop.Invoices.edit', $data);
    }

    public function destroy($id)
    {
        return Invoices::delete($id);
    }
}
