<?php
namespace App\Admin\Actions\Teams;
use App\Models\TeamUser;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class TeamUsers extends LazyRenderable
{
    public function grid(): Grid
    {
        $grid = new Grid(new TeamUser());
        $grid->model()->with(['user:id,name,avatar'])->where('team_id',$this->payload['id'])->orderByDesc('id');

        $grid->column('user.id','ID');
        $grid->column('user.name',trans('user.fields.name'));
        $grid->column('user.avatar',trans('user.fields.avatar'))->image('',50);
        $grid->column('created_at');
        $grid->quickSearch(['user.name']);
        $grid->paginate(10);

        $grid->disableRowSelector();
        $grid->disableActions();
        return $grid;
    }
}
