<?php

namespace App\Admin\Renderable\Activity;

use App\Models\Activity;
use Encore\Admin\Widgets\Table;
use Illuminate\Contracts\Support\Renderable;

class Grants implements Renderable
{

    public function render($key = null)
    {
        $activity = Activity::find($key);
        $items    = $activity->grants->map(function ($info) {
            return [
                'id'       => $info->id,
                'nickname' => $info->user_nickname,
            ];
        });

        $table = new Table(['Id', '渠道'], $items->toArray());

        return $table->render();

    }

}