<?php #CodeGenerator V3 Δ 19764d550321402bc82d7da99ad1bbd4 Δ DYNAMICALLY GENERATED FILE - Do not modify this line! Remove it completely to protect the file from changes.
/**
 * Model Class
 *
 * @version     3.0.$Revision:$
 * @version     SVN: $Id:$
 * @version     STUB: 1.6.0
 * @generated   2026-05-04 16:09:46
 * @package     bplan-base/globals
 * @subpackage  Models
 * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 * @copyright   Copyright (C) 2025, 2026 bplan-solutions GmbH & Co. KG <https://www.bplan-solutions.de/>
 * /Δ\
 */

namespace BplanBase\Globals\Models;


use BplanBase\Globals\Models\EntityType;
use BplanBase\Globals\Models\GlobalSetting;
use BplanBase\Globals\Models\ImportLog;
use BplanBase\Globals\Models\Language;
use BplanBase\Globals\Models\Location;
use BplanBase\Globals\Models\Module;
use BplanBase\Globals\Models\PrintJob;
use BplanBase\Globals\Models\Printer;
use BplanBase\Globals\Models\Role;
use BplanBase\Globals\Models\TenantExternalSystem;
use BplanBase\Globals\Models\TenantLocale;
use BplanBase\Globals\Models\TenantRecord;
use BplanBase\Globals\Models\TerminalConnection;
use BplanBase\Globals\Models\User;
use BplanBase\Globals\Observers\TenantObserver;
use BplanBase\Globals\Traits\HasActiveScope;
use BplanBase\Globals\Traits\HasNoInternalScope;
use BplanBase\Globals\Traits\HasOrderedScope;
use BplanBase\Globals\Traits\ModelHasMaterializedPath;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Spatie\Multitenancy\Models\Tenant as BaseTenant;


/**
 * Model Class
 *
 * @version     1.0.0 / 2026-05-04
 * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 */
#[ObservedBy([TenantObserver::class])]
class Tenant extends BaseTenant
{


/* +++ TRAITS +++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */


    use HasActiveScope;
    use HasNoInternalScope;
    use HasOrderedScope;
    use ModelHasMaterializedPath;
    use SoftDeletes;


/* +++ CLASS CONSTANTS +++ ++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ OBJECT MEMBERS +++ +++++++++++++++++++++++++++++++++++++++++++++++++++ */


    /**
     * The accessors to append to the model's array form.
     *
     * @var         array<int, string>
     *
     * @version     1.0.0 / 2026-05-04
     */
    protected $appends = [];


    /**
     * @var         array<string, string>
     *
     * @version     1.0.0 / 2026-05-04
     */
    protected $casts = [
        'active'     => 'boolean',
        'created_at' => 'datetime',
        'deleted_at' => 'datetime',
        'internal'   => 'boolean',
        'updated_at' => 'datetime',
    ];


    /**
     * The attributes that are mass assignable.
     *
     * @var         array<int, string>
     *
     * @version     1.0.0 / 2026-05-04
     */
    protected $fillable = [
        'active',
        'domain',
        'master_id',
    ];


    /**
     * The attributes that aren't mass assignable.
     *
     * @var         array<int, string>
     *
     * @version     1.0.0 / 2026-05-04
     */
    protected $guarded = [
        'created_at',
        'deleted_at',
        'identifier',
        'internal',
        'path',
        'updated_at',
        'uuid',
    ];


    /**
     * The attributes that should be hidden for serialization.
     *
     * @var         array<int, string>
     *
     * @version     1.0.0 / 2026-05-04
     */
    protected $hidden = [];


    /**
     * The table associated with the model.
     *
     * @var         string
     */
    protected $table = 'tenants';


    /**
     * Indicates if the model should be timestamped.
     *
     * @var         bool
     */
    public $timestamps = true;


/* +++ CLASS MEMBERS +++ ++++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ OBJECT METHODS +++ +++++++++++++++++++++++++++++++++++++++++++++++++++ */


    /**
     *
     * @return      BelongsToMany
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function assignedUsers(): BelongsToMany
    {
        return $this->belongsToMany(User::class, 'tenant_user', 'tenant_id', 'user_id')->withPivot('access_level', 'created_at', 'tenant_id', 'updated_at', 'user_id', 'uuid');

    } // assignedUsers()


    /**
     *
     * @return      HasMany
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function entityTypes(): HasMany
    {
        return $this->hasMany(EntityType::class, 'tenant_id');

    } // entityTypes()


    /**
     *
     * @return      HasMany
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function externalSystems(): HasMany
    {
        return $this->hasMany(TenantExternalSystem::class, 'tenant_id');

    } // externalSystems()


    /**
     *
     * @return      HasOne
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function globalSetting(): HasOne
    {
        return $this->hasOne(GlobalSetting::class, 'id');

    } // globalSetting()


    /**
     *
     * @return      HasMany
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function importLogs(): HasMany
    {
        return $this->hasMany(ImportLog::class, 'tenant_id');

    } // importLogs()


    /**
     *
     * @return      HasMany
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function languages(): HasMany
    {
        return $this->hasMany(Language::class, 'tenant_id');

    } // languages()


    /**
     *
     * @return      HasMany
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function locales(): HasMany
    {
        return $this->hasMany(TenantLocale::class, 'tenant_id');

    } // locales()


    /**
     *
     * @return      HasMany
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function locations(): HasMany
    {
        return $this->hasMany(Location::class, 'tenant_id');

    } // locations()


    /**
     *
     * @return      BelongsTo
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function masterTenant(): BelongsTo
    {
        return $this->belongsTo(Tenant::class, 'master_id');

    } // masterTenant()


    /**
     *
     * @return      BelongsToMany
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function modules(): BelongsToMany
    {
        return $this->belongsToMany(Module::class, 'module_tenant', 'tenant_id', 'module_id');

    } // modules()


    /**
     *
     * @return      HasMany
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function printJobs(): HasMany
    {
        return $this->hasMany(PrintJob::class, 'tenant_id');

    } // printJobs()


    /**
     *
     * @return      HasMany
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function printers(): HasMany
    {
        return $this->hasMany(Printer::class, 'tenant_id');

    } // printers()


    /**
     *
     * @return      HasMany
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function roles(): HasMany
    {
        return $this->hasMany(Role::class, 'tenant_id');

    } // roles()


    /**
     *
     * @return      HasMany
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function subTenants(): HasMany
    {
        return $this->hasMany(Tenant::class, 'master_id');

    } // subTenants()


    /**
     *
     * @return      HasOne
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function tenantRecord(): HasOne
    {
        return $this->hasOne(TenantRecord::class, 'id');

    } // tenantRecord()


    /**
     *
     * @return      HasMany
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function terminalConnections(): HasMany
    {
        return $this->hasMany(TerminalConnection::class, 'tenant_id');

    } // terminalConnections()


    /**
     *
     * @return      HasMany
     *
     * @version     1.0.0 / 2026-05-04
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function users(): HasMany
    {
        return $this->hasMany(User::class, 'tenant_id');

    } // users()


/* +++ CLASS METHODS +++ ++++++++++++++++++++++++++++++++++++++++++++++++++++ */


} // class Tenant extends BaseTenant {}
