<?php

namespace Hubleto\App\Community\Settings\Models;


use Hubleto\Framework\Db\Column\Lookup;
use Hubleto\Framework\Db\Column\Text;
use Hubleto\Framework\Db\Column\Varchar;
use Hubleto\App\Community\Auth\Models\User;

class TeamMember extends \Hubleto\Erp\Model
{
  public string $table = 'teams_members';
  public string $recordManagerClass = RecordManagers\TeamMember::class;

  public function describeColumns(): array
  {
    return array_merge(parent::describeColumns(), [
      'id_team' => (new Lookup($this, $this->translate("Team"), Team::class))->setRequired(),
      'id_member' => (new Lookup($this, $this->translate("Member"), User::class))->setReactComponent('InputUserSelect')->setRequired(),
    ]);
  }

  public function describeTable(): \Hubleto\Framework\Description\Table
  {
    $description = parent::describeTable();

    $description->ui['title'] = '';
    $description->ui['addButtonText'] = $this->translate('Add member to team');
    $description->show(['header', 'fulltextSearch', 'columnSearch', 'moreActionsButton']);
    $description->hide(['footer']);

    unset($description->columns['id_team']);

    return $description;
  }
}
