mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-04 03:54:04 +00:00
[4.x] Add more relation type annotations (#1424)
This pull request adds improved PHPDoc type annotations to several Eloquent relationship methods, enhancing static analysis and developer experience. These changes clarify the expected return types for relationships, making the codebase easier to understand and work with. Relationship method type annotations: * Added a detailed return type annotation to the `tenant` method in the `BelongsToTenant` trait, specifying the related model and the current class. * Added a detailed return type annotation to the `domains` method in the `HasDomains` trait, specifying the related model and the current class. * Added a detailed return type annotation to the `tenants` method in the `ResourceSyncing` class, specifying the related model and the current class.
This commit is contained in:
parent
3c0e21b726
commit
e3701f1cc1
3 changed files with 11 additions and 1 deletions
|
|
@ -17,6 +17,9 @@ trait BelongsToTenant
|
||||||
{
|
{
|
||||||
use FillsCurrentTenant;
|
use FillsCurrentTenant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return BelongsTo<\Illuminate\Database\Eloquent\Model&\Stancl\Tenancy\Contracts\Tenant, $this>
|
||||||
|
*/
|
||||||
public function tenant(): BelongsTo
|
public function tenant(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(config('tenancy.models.tenant'), Tenancy::tenantKeyColumn());
|
return $this->belongsTo(config('tenancy.models.tenant'), Tenancy::tenantKeyColumn());
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Stancl\Tenancy\Database\Concerns;
|
namespace Stancl\Tenancy\Database\Concerns;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Stancl\Tenancy\Contracts\Domain;
|
use Stancl\Tenancy\Contracts\Domain;
|
||||||
use Stancl\Tenancy\Tenancy;
|
use Stancl\Tenancy\Tenancy;
|
||||||
|
|
||||||
|
|
@ -14,7 +15,10 @@ use Stancl\Tenancy\Tenancy;
|
||||||
*/
|
*/
|
||||||
trait HasDomains
|
trait HasDomains
|
||||||
{
|
{
|
||||||
public function domains()
|
/**
|
||||||
|
* @return HasMany<\Illuminate\Database\Eloquent\Model&\Stancl\Tenancy\Contracts\Domain, $this>
|
||||||
|
*/
|
||||||
|
public function domains(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(config('tenancy.models.domain'), Tenancy::tenantKeyColumn());
|
return $this->hasMany(config('tenancy.models.domain'), Tenancy::tenantKeyColumn());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,9 @@ trait ResourceSyncing
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return BelongsToMany<\Illuminate\Database\Eloquent\Model&\Stancl\Tenancy\Database\Contracts\TenantWithDatabase, $this>
|
||||||
|
*/
|
||||||
public function tenants(): BelongsToMany
|
public function tenants(): BelongsToMany
|
||||||
{
|
{
|
||||||
return $this->morphToMany(config('tenancy.models.tenant'), 'tenant_resources', 'tenant_resources', 'resource_global_id', 'tenant_id', $this->getGlobalIdentifierKeyName())
|
return $this->morphToMany(config('tenancy.models.tenant'), 'tenant_resources', 'tenant_resources', 'resource_global_id', 'tenant_id', $this->getGlobalIdentifierKeyName())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue