<?php

namespace App\Admin\Controllers;

use App\Models\Dishes;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class DishesController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'Меню';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new Dishes());

        $grid->column('id', __('Id'));
        $grid->column('name', __('Название'));
        $grid->column('price', __('Цена'));
        $grid->column('weigh', __('Вес'));
        $grid->column('categories', __('Категория'));
        $grid->column('composition', __('Описание'));
        $grid->column('created_at', __('Created at'))->hide();
        $grid->column('updated_at', __('Updated at'))->hide();

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(Dishes::findOrFail($id));

        $show->field('id', __('Id'));
        $show->field('name', __('Название'));
        $show->field('price', __('Цена'));
        $show->field('weigh', __('Вес'));
        $show->field('categories', __('Категория'));
        $show->field('composition', __('Composition'));
        $show->field('created_at', __('Описание'));
        $show->field('updated_at', __('Updated at'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new Dishes());

        $form->textarea('name', __('Название'));
        $form->number('price', __('Цена'));
        $form->number('weigh', __('Вес'));
        $form->image('image', __('Изображение'));
        $form->text('categories', __('Категория'));
        $form->textarea('composition', __('Описание'));

        return $form;
    }
}
