<?php

namespace Ignite\Core\Models\Grid;

class InternalTable extends ParticipantTable
{
    /**
     * The report query.
     *
     * @return \Illuminate\Database\Query\Builder
     */
    public function query()
    {
        $columns = collect($this->getColumns())->keyBy('name')->except('actions')->keys()->toArray();

        return $this->applyScopes(
            $this->getConnection()->table('core_participant AS participant')
                 ->select($columns)
                 ->distinct()
                 ->leftJoin('core_user AS user', 'user.user_id', '=', 'participant.user_id')
                 ->where('user.internal', '=', 1)
                 ->where('user.status', $this->status)
                 ->whereNull('deleted_at')
        );
    }
}
