<?php

namespace App\Http\Controllers\Admin\Shop;

use App\Datatables\Admin\Shop\UnitiesDataTable;
use App\Http\Controllers\Controller;
use App\Repositories\Shop\Unities;
use Illuminate\Http\Request;

class UnityController extends Controller
{
    public function index(UnitiesDataTable $dataTable)
    {
        return $dataTable->render('Admin.Shop.Unities.list');
    }

    public function getOptionsByPackage($id)
    {
        return response()->json(Unities::getOptionsByPackage($id));
    }

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

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

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

    public function edit($id)
    {
        $data = [
            'unity' => Unities::get($id)->toArray(),
        ];

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

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