93 lines
2.6 KiB
PHP
93 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\UuidPrimaryKey;
|
|
use App\Exceptions\ModelNotFoundException;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\QueryException;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class Restaurante extends Model {
|
|
use UuidPrimaryKey, SoftDeletes;
|
|
|
|
protected $table = 'restaurantes';
|
|
protected $hidden = ['created_at', 'updated_at', 'deleted_at', 'pivot'];
|
|
protected $fillable = ['id', 'nombre'];
|
|
|
|
public static function findOrFail($id) {
|
|
$restaurante = Restaurante::find($id);
|
|
if(!$restaurante) throw new ModelNotFoundException("restaurant", $id);
|
|
return $restaurante;
|
|
}
|
|
|
|
public function canalesVenta() {
|
|
return $this->hasMany(CanalVenta::class, 'restaurante_id');
|
|
}
|
|
|
|
public function categorias() {
|
|
return $this->hasMany(Categoria::class, 'restaurante_id');
|
|
}
|
|
|
|
public function compras() {
|
|
return $this->hasMany(Compra::class, 'restaurante_id');
|
|
}
|
|
|
|
public function usuarios() {
|
|
return $this->belongsToMany(Usuario::class, 'usuarios_restaurantes', 'restaurante_id', 'usuario_id');
|
|
}
|
|
|
|
public function sectores() {
|
|
return $this->hasMany(Sector::class, 'restaurante_id');
|
|
}
|
|
|
|
public function zonasProduccion() {
|
|
return $this->hasMany(ZonaProduccion::class, 'restaurante_id');
|
|
}
|
|
|
|
public function proveedores() {
|
|
return $this->hasMany(Proveedor::class, 'restaurante_id');
|
|
}
|
|
|
|
public function ingredientes() {
|
|
return $this->hasMany(Ingrediente::class, 'restaurante_id');
|
|
}
|
|
|
|
public function productos() {
|
|
return $this->hasMany(Producto::class, 'restaurante_id');
|
|
}
|
|
|
|
public function ventas() {
|
|
return $this->hasMany(Venta::class, 'restaurante_id');
|
|
}
|
|
|
|
public function boletasElectronicas() {
|
|
return $this->hasMany(BoletaElectronica::class, 'restaurante_id');
|
|
}
|
|
|
|
public function boletasExentas() {
|
|
return $this->hasMany(BoletaExenta::class, 'restaurante_id');
|
|
}
|
|
|
|
public function cajas() {
|
|
return $this->hasMany(Caja::class, 'restaurante_id');
|
|
}
|
|
|
|
public function bodegaIngresos() {
|
|
return $this->hasMany(BodegaIngreso::class, 'restaurante_id');
|
|
}
|
|
|
|
public function bodegaEgresos() {
|
|
return $this->hasMany(BodegaEgreso::class, 'restaurante_id');
|
|
}
|
|
|
|
public function bodegaMovimientos() {
|
|
return $this->hasMany(BodegaMovimiento::class, 'restaurante_id');
|
|
}
|
|
|
|
public function bodegaActual() {
|
|
return $this->hasMany(BodegaActual::class, 'restaurante_id');
|
|
}
|
|
}
|