<?php
use backend\models\ActionLog;
use yii\data\ArrayDataProvider;

$actionLog = ActionLog::find()->where(['relatedid' => $model->id])->orderBy(['createddt' => SORT_DESC])->all();
$dataProvider = new ArrayDataProvider([
    'allModels' => $actionLog,
    'pagination' => [
        'pageSize' => 50,
    ],
    'sort' => [
        'attributes' => ['createddt','type', 'action', 'message'],
        'defaultOrder' => ['createddt' => SORT_DESC],
    ],
]);

?>
<div class="action-log">
    <h3>Action Log</h3>
    <?= \common\widgets\GridView::widget([
        'dataProvider' => $dataProvider,
        'rowOptions' => function ($model, $key, $index, $grid) {
            if (strtolower($model->type) === 'error') {
                return ['class' => 'text-danger'];
            }
            return ['class' => 'text-dark'];
        },
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'jobid',
            'relatedid',
            'createddt',
            'type',
            'action',
            'message',
        ],
    ]); ?>
</div>
