Modelo de base de datos en lumen
This commit is contained in:
17
backend/app/Models/Administrador.php
Normal file
17
backend/app/Models/Administrador.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Administrador extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'administradores';
|
||||
|
||||
public function usuario() {
|
||||
return $this->belongsTo(Usuario::class);
|
||||
}
|
||||
}
|
||||
21
backend/app/Models/BoletaElectronica.php
Normal file
21
backend/app/Models/BoletaElectronica.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class BoletaElectronica extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'boletas_electronicas';
|
||||
|
||||
public function venta() {
|
||||
return $this->belongsTo(Venta::class);
|
||||
}
|
||||
|
||||
public function restaurante() {
|
||||
return $this->belongsTo(Restaurante::class);
|
||||
}
|
||||
}
|
||||
21
backend/app/Models/BoletaExenta.php
Normal file
21
backend/app/Models/BoletaExenta.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class BoletaExenta extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'boletas_exentas';
|
||||
|
||||
public function venta() {
|
||||
return $this->belongsTo(Venta::class);
|
||||
}
|
||||
|
||||
public function restaurante() {
|
||||
return $this->belongsTo(Restaurante::class);
|
||||
}
|
||||
}
|
||||
25
backend/app/Models/CanalVenta.php
Normal file
25
backend/app/Models/CanalVenta.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CanalVenta extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'canales_venta';
|
||||
|
||||
public function tipoCanal() {
|
||||
return $this->belongsTo(TipoCanal::class);
|
||||
}
|
||||
|
||||
public function sector() {
|
||||
return $this->belongsTo(Sector::class);
|
||||
}
|
||||
|
||||
public function restaurante() {
|
||||
return $this->belongsTo(Restaurante::class);
|
||||
}
|
||||
}
|
||||
17
backend/app/Models/Categoria.php
Normal file
17
backend/app/Models/Categoria.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Categoria extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'categorias';
|
||||
|
||||
public function restaurante() {
|
||||
return $this->belongsTo(Restaurante::class);
|
||||
}
|
||||
}
|
||||
29
backend/app/Models/Compra.php
Normal file
29
backend/app/Models/Compra.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Compra extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'compras';
|
||||
|
||||
public function compraIngredientes() {
|
||||
return $this->hasMany(CompraIngrediente::class);
|
||||
}
|
||||
|
||||
public function facturas() {
|
||||
return $this->hasMany(Factura::class);
|
||||
}
|
||||
|
||||
public function restaurante() {
|
||||
return $this->belongsTo(Restaurante::class);
|
||||
}
|
||||
|
||||
public function proveedor() {
|
||||
return $this->belongsTo(Proveedor::class);
|
||||
}
|
||||
}
|
||||
21
backend/app/Models/CompraIngrediente.php
Normal file
21
backend/app/Models/CompraIngrediente.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CompraIngrediente extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'compra_ingredientes';
|
||||
|
||||
public function ingrediente() {
|
||||
return $this->belongsTo(Ingrediente::class);
|
||||
}
|
||||
|
||||
public function compra() {
|
||||
return $this->belongsTo(Compra::class);
|
||||
}
|
||||
}
|
||||
13
backend/app/Models/EstadoProduccion.php
Normal file
13
backend/app/Models/EstadoProduccion.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class EstadoProduccion extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'estados_produccion';
|
||||
}
|
||||
17
backend/app/Models/Factura.php
Normal file
17
backend/app/Models/Factura.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Factura extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'facturas';
|
||||
|
||||
public function compra() {
|
||||
return $this->belongsTo(Compra::class);
|
||||
}
|
||||
}
|
||||
22
backend/app/Models/Ingrediente.php
Normal file
22
backend/app/Models/Ingrediente.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Ingrediente extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'ingredientes';
|
||||
|
||||
|
||||
public function recetas() {
|
||||
return $this->hasMany(Receta::class, 'ingrediente_id');
|
||||
}
|
||||
|
||||
public function restaurante() {
|
||||
return $this->belongsTo(Restaurante::class);
|
||||
}
|
||||
}
|
||||
17
backend/app/Models/Mesero.php
Normal file
17
backend/app/Models/Mesero.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Mesero extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'meseros';
|
||||
|
||||
public function usuario() {
|
||||
return $this->belongsTo(Usuario::class);
|
||||
}
|
||||
}
|
||||
29
backend/app/Models/Producto.php
Normal file
29
backend/app/Models/Producto.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Producto extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'productos';
|
||||
|
||||
public function recetas() {
|
||||
return $this->hasMany(Receta::class, 'producto_id');
|
||||
}
|
||||
|
||||
public function categoria() {
|
||||
return $this->belongsTo(Categoria::class);
|
||||
}
|
||||
|
||||
public function zonaProduccion() {
|
||||
return $this->belongsTo(ZonaProduccion::class);
|
||||
}
|
||||
|
||||
public function restaurante() {
|
||||
return $this->belongsTo(Restaurante::class);
|
||||
}
|
||||
}
|
||||
21
backend/app/Models/Productor.php
Normal file
21
backend/app/Models/Productor.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Productor extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'productores';
|
||||
|
||||
public function usuario() {
|
||||
return $this->belongsTo(Usuario::class);
|
||||
}
|
||||
|
||||
public function zonaProduccion() {
|
||||
return $this->belongsTo(ZonaProduccion::class);
|
||||
}
|
||||
}
|
||||
17
backend/app/Models/Proveedor.php
Normal file
17
backend/app/Models/Proveedor.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Proveedor extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'proveedores';
|
||||
|
||||
public function restaurante() {
|
||||
return $this->belongsTo(Restaurante::class);
|
||||
}
|
||||
}
|
||||
17
backend/app/Models/Recaudador.php
Normal file
17
backend/app/Models/Recaudador.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Recaudador extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'recaudadores';
|
||||
|
||||
public function usuario() {
|
||||
return $this->belongsTo(Usuario::class);
|
||||
}
|
||||
}
|
||||
20
backend/app/Models/Receta.php
Normal file
20
backend/app/Models/Receta.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Receta extends Model {
|
||||
use UuidPrimaryKey;
|
||||
|
||||
protected $table = 'recetas';
|
||||
|
||||
public function ingrediente() {
|
||||
return $this->belongsTo(Ingrediente::class);
|
||||
}
|
||||
|
||||
public function producto() {
|
||||
return $this->belongsTo(Producto::class);
|
||||
}
|
||||
}
|
||||
17
backend/app/Models/Restaurante.php
Normal file
17
backend/app/Models/Restaurante.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Restaurante extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'restaurantes';
|
||||
|
||||
public function usuarios() {
|
||||
return $this->belongsToMany(Usuario::class, 'usuarios_restaurantes', 'restaurante_id', 'usuario_id');
|
||||
}
|
||||
}
|
||||
17
backend/app/Models/Sector.php
Normal file
17
backend/app/Models/Sector.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Sector extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'sectores';
|
||||
|
||||
public function restaurante() {
|
||||
return $this->belongsTo(Restaurante::class);
|
||||
}
|
||||
}
|
||||
13
backend/app/Models/TipoCanal.php
Normal file
13
backend/app/Models/TipoCanal.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class TipoCanal extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'tipos_canal';
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Laravel\Lumen\Auth\Authorizable;
|
||||
|
||||
class User extends Model implements AuthenticatableContract, AuthorizableContract
|
||||
{
|
||||
use Authenticatable, Authorizable, HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
];
|
||||
}
|
||||
17
backend/app/Models/Usuario.php
Normal file
17
backend/app/Models/Usuario.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Usuario extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'usuarios';
|
||||
|
||||
public function restaurantes() {
|
||||
return $this->belongsToMany(Restaurante::class, 'usuarios_restaurantes', 'usuario_id', 'restaurante_id');
|
||||
}
|
||||
}
|
||||
29
backend/app/Models/Venta.php
Normal file
29
backend/app/Models/Venta.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Venta extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'ventas';
|
||||
|
||||
public function mesero() {
|
||||
return $this->belongsTo(Mesero::class);
|
||||
}
|
||||
|
||||
public function canal() {
|
||||
return $this->belongsTo(CanalVenta::class);
|
||||
}
|
||||
|
||||
public function restaurante() {
|
||||
return $this->belongsTo(Restaurante::class);
|
||||
}
|
||||
|
||||
public function productos() {
|
||||
return $this->hasMany(VentaProducto::class);
|
||||
}
|
||||
}
|
||||
25
backend/app/Models/VentaProducto.php
Normal file
25
backend/app/Models/VentaProducto.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class VentaProducto extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'venta_productos';
|
||||
|
||||
public function venta() {
|
||||
return $this->belongsTo(Venta::class);
|
||||
}
|
||||
|
||||
public function producto() {
|
||||
return $this->belongsTo(Producto::class);
|
||||
}
|
||||
|
||||
public function estado() {
|
||||
return $this->belongsTo(EstadoProduccion::class);
|
||||
}
|
||||
}
|
||||
17
backend/app/Models/ZonaProduccion.php
Normal file
17
backend/app/Models/ZonaProduccion.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ZonaProduccion extends Model {
|
||||
use UuidPrimaryKey, SoftDeletes;
|
||||
|
||||
protected $table = 'zonas_produccion';
|
||||
|
||||
public function restaurante() {
|
||||
return $this->belongsTo(Restaurante::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user