<?php

namespace Hubleto\App\Community\OAuth\Models;

use Hubleto\Framework\Db\Column\Varchar;
use Hubleto\Framework\Db\Column\VarcBooleanhar;

class Client extends \Hubleto\Erp\Model
{
  public string $table = 'oauth_clients';
  public string $recordManagerClass = RecordManagers\Client::class;
  public ?string $lookupSqlValue = 'concat("Client #", {%TABLE%}.id)';

  public function describeColumns(): array
  {
    return array_merge(parent::describeColumns(), [
      'client_id' => (new Varchar($this, $this->translate('Client Id')))->setDefaultVisible(),
      'client_secret' => (new Varchar($this, $this->translate('Client Secret')))->setDefaultVisible(),
      'name' => (new Varchar($this, $this->translate('Name')))->setDefaultVisible(),
      'redirect_uri' => (new Varchar($this, $this->translate('Redirect Uri')))->setDefaultVisible(),
    ]);
  }

  public function describeTable(): \Hubleto\Framework\Description\Table
  {
    $description = parent::describeTable();
    $description->ui['addButtonText'] = $this->translate('Add Client');
    $description->ui['showHeader'] = true;
    $description->ui['showFulltextSearch'] = true;
    $description->ui['showFooter'] = false;
    return $description;
  }

}
