Mantenedor de compras!
This commit is contained in:
@@ -11,8 +11,17 @@ class Compra extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'compras';
|
||||
protected $fillable = [
|
||||
'id', 'fecha_compra', 'proveedor_id', 'en_arqueo', 'restaurante_id'
|
||||
];
|
||||
|
||||
public function compraIngredientes() {
|
||||
public static function findOrFail($id) {
|
||||
$compra = Compra::find($id);
|
||||
if(!$compra) throw new ModelNotFoundException("compra", $id);
|
||||
return $compra;
|
||||
}
|
||||
|
||||
public function ingredientes() {
|
||||
return $this->hasMany(CompraIngrediente::class);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ class CompraIngrediente extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'compra_ingredientes';
|
||||
protected $fillable = ['id', 'unidades', 'monto_unitario', 'compra_id', 'ingrediente_id'];
|
||||
|
||||
public function ingrediente() {
|
||||
return $this->belongsTo(Ingrediente::class);
|
||||
|
||||
@@ -11,6 +11,13 @@ class Factura extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'facturas';
|
||||
protected $fillable = ['id', 'numero', 'monto_bruto', 'compra_id'];
|
||||
|
||||
public static function findOrFail($id) {
|
||||
$factura = Factura::find($id);
|
||||
if(!$factura) throw new ModelNotFoundException("factura", $id);
|
||||
return $factura;
|
||||
}
|
||||
|
||||
public function compra() {
|
||||
return $this->belongsTo(Compra::class);
|
||||
|
||||
@@ -2,13 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\CanalVenta;
|
||||
use App\Models\Sector;
|
||||
use App\Models\ZonaProduccion;
|
||||
use App\Models\Categoria;
|
||||
use App\Models\Proveedor;
|
||||
use App\Models\Ingrediente;
|
||||
use App\Models\Producto;
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use App\Exceptions\ModelNotFoundException;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -60,4 +53,8 @@ class Restaurante extends Model {
|
||||
public function productos() {
|
||||
return $this->hasMany(Producto::class, 'restaurante_id');
|
||||
}
|
||||
|
||||
public function compras() {
|
||||
return $this->hasMany(Compra::class, 'restaurante_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user