Proveedores

This commit is contained in:
2021-07-12 17:11:04 -04:00
parent c0fdba3072
commit 29f3b11ec5
4 changed files with 163 additions and 0 deletions

View File

@@ -10,6 +10,16 @@ class Proveedor extends Model {
use UuidPrimaryKey, SoftDeletes;
protected $table = 'proveedores';
protected $fillable = [
'id', 'rut', 'nombre', 'descripcion',
'direccion', 'telefono', 'restaurante_id'
];
public static function findOrFail($id) {
$proveedor = Proveedor::find($id);
if(!$proveedor) throw new ModelNotFoundException("proveedor", $id);
return $proveedor;
}
public function restaurante() {
return $this->belongsTo(Restaurante::class);

View File

@@ -6,6 +6,7 @@ use App\Models\CanalVenta;
use App\Models\Sector;
use App\Models\ZonaProduccion;
use App\Models\Categoria;
use App\Models\Proveedor;
use App\Traits\UuidPrimaryKey;
use App\Exceptions\ModelNotFoundException;
use Illuminate\Database\Eloquent\Model;
@@ -45,4 +46,8 @@ class Restaurante extends Model {
public function categorias() {
return $this->hasMany(Categoria::class, 'restaurante_id');
}
public function proveedores() {
return $this->hasMany(Proveedor::class, 'restaurante_id');
}
}