<?php

namespace App\Http\Controllers\Admin\Shop;

use App\Datatables\Admin\Shop\DeliveryTypeCalculationsDataTable;
use App\Repositories\Shop\DeliveryTypeCalculations;
use App\Repositories\Shop\DeliveryTypes;
use Illuminate\Http\Request;

class DeliveryTypeCalculationController extends Controller
{
    public function index(DeliveryTypeCalculationsDataTable $dataTable)
    {
        return $dataTable->render('Admin.Shop.DeliveryTypeCalculations.list');
    }

    public function create()
    {
        $data = [
            'delivery_types' => DeliveryTypes::getOptions(),
        ];

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

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

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

    public function edit($id)
    {
        $data = [
            'calcul' => DeliveryTypeCalculations::get($id)->toArray(),
            'delivery_types' => DeliveryTypes::getOptions(),
        ];

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

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