<?php

namespace App\Http\Controllers\Backend;

use App\DataTables\Users\UserDataTable;
use App\DataTables\Users\UserDataTableEditor;
use App\Http\Controllers\Controller;
use App\Models\UserManagement\UserType;
use Illuminate\Http\Request;

class CustomerController extends Controller{

    public function __construct(){

        $this->middleware('permission:customer-list')
            ->only(["index"]);

        $this->middleware('permission:customer-show')
            ->only(["show"]);

        $this->middleware('permission:customer-create')
            ->only(['create',"dtEdit"]);

        $this->middleware('permission:customer-update')
            ->only(['update',"dtEdit"]);

        $this->middleware('permission:customer-delete')
            ->only(['delete',"deleteMany","dtEdit"]);

    }

    public function index( ){
        $dataTable = new UserDataTable(UserType::CUSTOMER);
        $title = __("Manage Customers");
        return $dataTable->render('backend.users.dt-index',compact("title"));
    }

    public function dtEdit(UserDataTableEditor $editor){
        return $editor->process(request());
    }
}
