41 lines
835 B
PHP
41 lines
835 B
PHP
<?php
|
|
|
|
namespace App\Domains\Product\Models;
|
|
|
|
use App\Domains\Tenant\Models\Tenant;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
#[Fillable([
|
|
'tenant_codigo',
|
|
'categoria_id',
|
|
'slug',
|
|
'nombre',
|
|
'descripcion',
|
|
'precio',
|
|
])]
|
|
class Product extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'productos';
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'categoria_id' => 'integer',
|
|
'precio' => 'decimal:2',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Tenant, $this>
|
|
*/
|
|
public function tenant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Tenant::class, 'tenant_codigo', 'codigo');
|
|
}
|
|
}
|