Skip to content

Commit

Permalink
Adicionada funcionalidade que busca reservas em dias específicos tamb…
Browse files Browse the repository at this point in the history
…ém para reservas feitas no sistema legado
  • Loading branch information
jpmoura committed Feb 26, 2017
1 parent 0de89f2 commit dca3f63
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/Http/Controllers/ReservaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Recurso;
use App\Regra;
use App\Reserva;
use App\ReservaLegado;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Log;
Expand Down Expand Up @@ -196,10 +197,14 @@ public function delete(Reserva $reserva)
private function searchAllocationsAt($data, $recurso)
{

// Reservas cadastradas no sistema atual
$reservas = Reserva::with('usuario')->where('data', $data)->where('recurso_id', $recurso->id)->get();

// TODO buscar por reservas antigas. Reservas antigas e usuários antigos precisam estar em modelos e tabelas separados
//$allocations = array_merge($oldAllocations, $newAllocations);
// Reservas cadastradas no sistema legado
$reservasAntigas = ReservaLegado::with('usuario')->where('data', $data)->where('recurso_id', $recurso->id)->get();

// Concatenação de resultados
foreach ($reservasAntigas as $antiga) $reservas->add($antiga);

return $reservas;
}
Expand Down
23 changes: 23 additions & 0 deletions app/ReservaLegado.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class ReservaLegado extends Model
{
public $table = 'reservas_legado';
public $timestamps = false;

protected $hidden = [
'id',
];

/**
* Recupera o usuário da reserva feita no sistema legado.
*/
public function usuario()
{
return $this->belongsTo('App\UsuarioLegado');
}
}
23 changes: 23 additions & 0 deletions app/UsuarioLegado.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class UsuarioLegado extends Model
{
public $timestamps = false;
public $table = 'usuarios_legado';

protected $hidden = [
'id',
];

/**
* Recupera as reservas feitas pelo usuário no sistema legado.
*/
public function reservas()
{
return $this->hasMany('App\ReservaLegado');
}
}

0 comments on commit dca3f63

Please sign in to comment.