2024-03-11 19:54:52 -03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Producto extends Model
|
|
|
|
{
|
2024-03-12 17:52:52 -03:00
|
|
|
/**
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
*
|
|
|
|
* @var array<int, string>
|
|
|
|
*/
|
|
|
|
protected $fillable = [
|
2024-03-14 23:04:54 -03:00
|
|
|
'name', 'price', 'solidario', 'bono', 'categoria_id', 'barrio_id'
|
2024-03-12 17:52:52 -03:00
|
|
|
];
|
|
|
|
|
2024-03-12 17:05:15 -03:00
|
|
|
/**
|
|
|
|
* La categoría a la que pertenece el producto.
|
|
|
|
*/
|
|
|
|
public function categoria(): BelongsTo
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Categoria::class);
|
|
|
|
}
|
|
|
|
|
2024-03-11 19:54:52 -03:00
|
|
|
/**
|
|
|
|
* Los pedidos que tienen al producto.
|
|
|
|
*/
|
|
|
|
public function pedidos(): BelongsToMany
|
|
|
|
{
|
2024-03-15 01:34:57 -03:00
|
|
|
return $this->belongsToMany(Pedido::class)->withPivot(['cantidad','total']);
|
2024-03-11 19:54:52 -03:00
|
|
|
}
|
2024-03-12 17:18:00 -03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Las caracteristicas que pertenecen al producto.
|
|
|
|
*/
|
|
|
|
public function caracteristicas(): BelongsToMany
|
|
|
|
{
|
|
|
|
return $this->belongsToMany(Caracteristica::class);
|
|
|
|
}
|
2024-03-14 23:04:54 -03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* El barrio a la que pertenece el producto.
|
|
|
|
*/
|
|
|
|
public function barrio(): BelongsTo
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Barrio::class);
|
|
|
|
}
|
2024-03-11 19:54:52 -03:00
|
|
|
}
|