Refactor project structure to use domain-oriented architecture; add Product and Tenant domains with controllers, models, requests, resources, and routes
This commit is contained in:
38
app/Domains/Tenant/Models/Tenant.php
Normal file
38
app/Domains/Tenant/Models/Tenant.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Tenant\Models;
|
||||
|
||||
use App\Domains\Product\Models\Product;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
#[Fillable([
|
||||
'codigo',
|
||||
'nombre',
|
||||
'dominio',
|
||||
])]
|
||||
class Tenant extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* @return HasMany<Product, $this>
|
||||
*/
|
||||
public function productos(): HasMany
|
||||
{
|
||||
return $this->hasMany(Product::class, 'tenant_codigo', 'codigo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsToMany<TenantProp, $this>
|
||||
*/
|
||||
public function tenantProps(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(TenantProp::class, 'tenant_prop_definitions', 'tenant_codigo', 'prop_codigo', 'codigo', 'codigo')
|
||||
->withPivot('valor')
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user