<?php

namespace App\Community\Controllers;

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

class DocterController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '用户管理';

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

//        $grid->model()->whereHas('orgdocter')->where(['organziation_id'=>Admin::user()->org_id]);
        $grid->column('id', __('Id'));
        $grid->column('type', __('Type'));
        $grid->column('name', __('Name'));
        $grid->column('phone', __('Phone'));
        $grid->column('sex', __('Sex'));
        $grid->column('office_id', __('office id'));
        $grid->column('qualification_id', __('Qualification id'));
        $grid->column('service_persons', __('Service persons'));

        return $grid;
    }

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

        $show->field('id', __('Id'));
        $show->field('type', __('Type'));
        $show->field('name', __('Name'));
        $show->field('phone', __('Phone'));
        $show->field('sex', __('Sex'));
        $show->field('birthday', __('Birthday'));
        $show->field('avatar', __('Avatar'));
        $show->field('status', __('Status'));
        $show->field('label', __('Label'));
        $show->field('sign', __('Sign'));
        $show->field('intro', __('Intro'));
        $show->field('office_id', __('Office id'));
        $show->field('qualification_id', __('Qualification id'));
        $show->field('score', __('Score'));
        $show->field('service_persons', __('Service persons'));
        $show->field('eva_num', __('Eva num'));
        $show->field('service_days', __('Service days'));
        $show->field('phone_minutes', __('Phone minutes'));
        $show->field('chat_price', __('Chat price'));
        $show->field('phone_price', __('Phone price'));
        $show->field('appoint_price', __('Appoint price'));
        $show->field('is_chat', __('Is chat'));
        $show->field('is_phone', __('Is phone'));
        $show->field('is_appoint', __('Is appoint'));
        $show->field('latitude', __('Latitude'));
        $show->field('longitude', __('Longitude'));
        $show->field('created_at', __('Created at'));
        $show->field('updated_at', __('Updated at'));

        return $show;
    }

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

        $form->switch('type', __('Type'));
        $form->text('name', __('Name'));
        $form->mobile('phone', __('Phone'));
        $form->switch('sex', __('Sex'));
        $form->text('birthday', __('Birthday'));
        $form->image('avatar', __('Avatar'));
        $form->switch('status', __('Status'))->default(1);
        $form->text('label', __('Label'));
        $form->text('sign', __('Sign'));
        $form->text('intro', __('Intro'));
        $form->number('office_id', __('Office id'));
        $form->number('qualification_id', __('Qualification id'));
        $form->decimal('score', __('Score'))->default(0.0);
        $form->number('service_persons', __('Service persons'));
        $form->number('eva_num', __('Eva num'));
        $form->number('service_days', __('Service days'));
        $form->number('phone_minutes', __('Phone minutes'));
        $form->number('chat_price', __('Chat price'));
        $form->number('phone_price', __('Phone price'));
        $form->number('appoint_price', __('Appoint price'));
        $form->switch('is_chat', __('Is chat'))->default(1);
        $form->switch('is_phone', __('Is phone'))->default(1);
        $form->switch('is_appoint', __('Is appoint'))->default(1);
        $form->decimal('latitude', __('Latitude'))->default(0.0000000);
        $form->decimal('longitude', __('Longitude'))->default(0.0000000);

        return $form;
    }
}
