<?php

namespace App\Admin\Controllers;

use App\Services\ShopServiceService;
use Slowlyo\OwlAdmin\Controllers\AdminController;

/**
 * 店铺服务
 *
 * @property ShopServiceService $service
 */
class ShopServiceController extends AdminController
{
	protected string $serviceName = ShopServiceService::class;

	public function list()
	{
		$crud = $this->baseCRUD()
			->filterTogglable(false)
			->headerToolbar([
				$this->createButton('dialog'),
				...$this->baseHeaderToolBar()
			])
			->columns([
				amis()->TableColumn('id', 'ID')->sortable(),
				amis()->TableColumn('shop_id', '店铺编号'),
				amis()->TableColumn('service_id', '服务项目编号'),
				amis()->TableColumn('name', '服务项目名称'),
				amis()->TableColumn('cover', '服务项目封面'),
				amis()->TableColumn('price', '服务项目价格'),
				amis()->TableColumn('duration', '服务时长(分钟)')->sortable(),
				amis()->TableColumn('type', '服务类型'),
				amis()->TableColumn('state', '状态'),
				amis()->TableColumn('created_at', admin_trans('admin.created_at'))->type('datetime')->sortable(),
				amis()->TableColumn('updated_at', admin_trans('admin.updated_at'))->type('datetime')->sortable(),
				$this->rowActions('dialog')
			]);

		return $this->baseList($crud);
	}

	public function form($isEdit = false)
	{
		return $this->baseForm()->body([
			amis()->TextControl('shop_id', '店铺编号'),
			amis()->TextControl('service_id', '服务项目编号'),
			amis()->TextControl('name', '服务项目名称'),
			amis()->TextControl('cover', '服务项目封面'),
			amis()->TextControl('price', '服务项目价格'),
			amis()->TextControl('duration', '服务时长(分钟)'),
			amis()->TextControl('type', '服务类型'),
			amis()->TextControl('state', '状态'),
		]);
	}

	public function detail()
	{
		return $this->baseDetail()->body([
			amis()->TextControl('id', 'ID')->static(),
			amis()->TextControl('shop_id', '店铺编号')->static(),
			amis()->TextControl('service_id', '服务项目编号')->static(),
			amis()->TextControl('name', '服务项目名称')->static(),
			amis()->TextControl('cover', '服务项目封面')->static(),
			amis()->TextControl('price', '服务项目价格')->static(),
			amis()->TextControl('duration', '服务时长(分钟)')->static(),
			amis()->TextControl('type', '服务类型')->static(),
			amis()->TextControl('state', '状态')->static(),
			amis()->TextControl('created_at', admin_trans('admin.created_at'))->static(),
			amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(),
		]);
	}
}