<?php
namespace App\Admin\Actions\Games;
use App\Models\GameUser;
use App\Models\GameUserScore;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class GameUserScores extends LazyRenderable
{
    public function grid(): Grid
    {
        $grid = new Grid(new GameUserScore());
        $grid->model()
            ->with(['changeUser:id,name,avatar','gameUser:id,level,type'])
            ->leftJoin('course_holes','course_holes.id','=','game_user_scores.hole_id')
            ->where('game_user_scores.game_user_id',$this->payload['id'])
            ->select(['game_user_scores.*','course_holes.sort'])
            ->orderBy('sort','asc');

        $grid->column('sort','球洞号');
        $grid->column('score','分数');
        $grid->column('gameUser.level','T台')->using([1=>'红',2=>"白",3=>"蓝",4=>"金"])->label(['gray','red','write','blue','gold']);
        $grid->column('gameUser.type','类型')->using([1=>'正常',2=>"虚拟"])->label(['gray','green','gray']);
        $grid->column('created_at','时间');
//        $grid->quickSearch(['user.name']);
        $grid->paginate(10);
        $grid->disableRowSelector();
        $grid->disableActions();
//        $grid->actions(function (Grid\Displayers\Actions $actionss) {
//            $actionss->disableView();
//            $actionss->disableEdit();
//        });

        return $grid;
    }
}
