43 lines
899 B
PHP
43 lines
899 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Producto extends Model
|
|
{
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'name', 'price', 'solidario', 'bono', 'categoria_id'
|
|
];
|
|
|
|
/**
|
|
* La categoría a la que pertenece el producto.
|
|
*/
|
|
public function categoria(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Categoria::class);
|
|
}
|
|
|
|
/**
|
|
* Los pedidos que tienen al producto.
|
|
*/
|
|
public function pedidos(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Pedido::class);
|
|
}
|
|
|
|
/**
|
|
* Las caracteristicas que pertenecen al producto.
|
|
*/
|
|
public function caracteristicas(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Caracteristica::class);
|
|
}
|
|
}
|