<?php

namespace Modules\User\Renderable;

use Encore\Admin\Widgets\Table;
use Illuminate\Contracts\Support\Renderable;
use Modules\User\Models\User;

class UserLog implements Renderable
{

    public function render($key = null)
    {
        $user = User::find($key);
        $data = [];
        foreach ($user->logs as $log) {
            $data[] = [
                'admin'      => $log->admin->name,
                'remark'     => $log->remark,
                'created_at' => $log->created_at->toDateTimeString(),
            ];
        }


        $table = new Table(['操作人', '备注', '添加时间'], $data);

        return $table->render();

    }

}