<?php

namespace App\Admin\Controllers;

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

/**
 * 技师开通服务项目
 *
 * @property CoachProjectService $service
 */
class CoachProjectController extends AdminController
{
	protected string $serviceName = CoachProjectService::class;

	public function list()
	{
		$crud = $this->baseCRUD()
			->filterTogglable(false)
			->headerToolbar([
				$this->createButton('dialog'),
				...$this->baseHeaderToolBar()
			])
			->columns([
				amis()->TableColumn('id', 'ID')->sortable(),
				amis()->TableColumn('coach_id', '技师ID'),
				amis()->TableColumn('project_id', '项目ID'),
				amis()->TableColumn('discount_amount', '优惠金额'),
				amis()->TableColumn('service_gender', '服务性别(all:不限 male:男 female:女)'),
				amis()->TableColumn('service_distance', '服务距离(米)')->sortable(),
				amis()->TableColumn('traffic_fee_type', '收取路费(free:免费 one_way:单程 round_trip:双程)'),
				amis()->TableColumn('traffic_fee', '路费金额'),
				amis()->TableColumn('state', '状态(enable:启用 disable:禁用)'),
				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('coach_id', '技师ID'),
			amis()->TextControl('project_id', '项目ID'),
			amis()->TextControl('discount_amount', '优惠金额'),
			amis()->TextControl('service_gender', '服务性别(all:不限 male:男 female:女)'),
			amis()->TextControl('service_distance', '服务距离(米)'),
			amis()->TextControl('traffic_fee_type', '收取路费(free:免费 one_way:单程 round_trip:双程)'),
			amis()->TextControl('traffic_fee', '路费金额'),
			amis()->TextControl('state', '状态(enable:启用 disable:禁用)'),
		]);
	}

	public function detail()
	{
		return $this->baseDetail()->body([
			amis()->TextControl('id', 'ID')->static(),
			amis()->TextControl('coach_id', '技师ID')->static(),
			amis()->TextControl('project_id', '项目ID')->static(),
			amis()->TextControl('discount_amount', '优惠金额')->static(),
			amis()->TextControl('service_gender', '服务性别(all:不限 male:男 female:女)')->static(),
			amis()->TextControl('service_distance', '服务距离(米)')->static(),
			amis()->TextControl('traffic_fee_type', '收取路费(free:免费 one_way:单程 round_trip:双程)')->static(),
			amis()->TextControl('traffic_fee', '路费金额')->static(),
			amis()->TextControl('state', '状态(enable:启用 disable:禁用)')->static(),
			amis()->TextControl('created_at', admin_trans('admin.created_at'))->static(),
			amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(),
		]);
	}
}