<?php

namespace App\Datatables\Admin\Core;

use App\Datatables\ParentDataTable as DataTable;
use App\Models\Core\Comment;
use Yajra\DataTables\Html\Column;

class CommentsDataTable extends DataTable
{
    public $model_name = 'comments';

    public function __construct()
    {
        $this->url = route('Admin.Core.Comments.index');
    }

    public function query(Comment $model)
    {
        $model = $model::with(['commentator'])->select('*');

        return $this->buildQuery($model);
    }

    protected function getColumns()
    {
        return [
            Column::make('updated_at')->title(__('date'))->width('80')->class('text-center')->searchable(false),
            Column::make('commentator.name')->title(__('name'))->searchable(false),
            Column::make('comment')->title(__('comments'))->searchable(false),
            $this->makeColumnButtons(),
        ];
    }
}
