2024-03-11 19:41:52 -03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Pedido extends Model
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
*
|
|
|
|
* @var array<int, string>
|
|
|
|
*/
|
|
|
|
protected $fillable = [
|
|
|
|
'name',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* El barrio al que pertenece el pedido.
|
|
|
|
*/
|
|
|
|
public function barrio(): BelongsTo
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Barrio::class);
|
|
|
|
}
|
|
|
|
|
2024-03-11 19:55:35 -03:00
|
|
|
/**
|
|
|
|
* Los productos que pertenecen al pedido.
|
|
|
|
*/
|
|
|
|
public function productos(): BelongsToMany
|
|
|
|
{
|
2024-03-15 01:34:57 -03:00
|
|
|
return $this->belongsToMany(Producto::class)->withPivot(['cantidad','total']);
|
2024-03-11 19:55:35 -03:00
|
|
|
}
|
2024-03-11 19:41:52 -03:00
|
|
|
}
|