Agrega Productos y sus recetas

This commit is contained in:
2021-07-12 19:10:43 -04:00
parent df5238850e
commit d3713e2f93
10 changed files with 408 additions and 1 deletions

View File

@@ -11,6 +11,16 @@ class Producto extends Model {
use UuidPrimaryKey, SoftDeletes;
protected $table = 'productos';
protected $fillable = [
'id', 'nombre', 'precio_venta', 'categoria_id',
'zona_produccion_id', 'restaurante_id'
];
public static function findOrFail($id) {
$producto = Producto::find($id);
if(!$producto) throw new ModelNotFoundException("producto", $id);
return $producto;
}
public function recetas() {
return $this->hasMany(Receta::class, 'producto_id');