2017-12-26 05:19:34 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Repositories;
|
|
|
|
|
|
|
|
use App\Models\Acars;
|
2017-12-28 06:47:22 +08:00
|
|
|
use App\Models\Pirep;
|
|
|
|
use App\Models\Enums\PirepState;
|
|
|
|
use App\Models\Enums\PirepStatus;
|
|
|
|
|
2017-12-26 05:19:34 +08:00
|
|
|
use App\Repositories\Traits\CacheableRepository;
|
|
|
|
use Prettus\Repository\Contracts\CacheableInterface;
|
|
|
|
|
2017-12-28 06:47:22 +08:00
|
|
|
class AcarsRepository extends BaseRepository //implements CacheableInterface
|
2017-12-26 05:19:34 +08:00
|
|
|
{
|
2017-12-28 06:47:22 +08:00
|
|
|
//use CacheableRepository;
|
2017-12-26 05:19:34 +08:00
|
|
|
|
|
|
|
public function model()
|
|
|
|
{
|
|
|
|
return Acars::class;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function forPirep($pirep_id)
|
|
|
|
{
|
|
|
|
return $this->findWhere(['pirep_id' => $pirep_id]);
|
|
|
|
}
|
2017-12-28 06:47:22 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get all of the PIREPS that are in-progress, and then
|
|
|
|
* get the latest update for those flights
|
|
|
|
* @return Pirep
|
|
|
|
*/
|
|
|
|
public function getPositions()
|
|
|
|
{
|
|
|
|
return Pirep::with(['airline', 'position'])
|
|
|
|
->where(['state' => PirepState::IN_PROGRESS])
|
|
|
|
->get();
|
|
|
|
|
|
|
|
/*return Pirep::with(['acars' => function($q) {
|
|
|
|
return $q->limit(1);
|
|
|
|
}])->where(['state' => PirepState::IN_PROGRESS])->get();*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function getAllAcarsPoints()
|
|
|
|
{
|
|
|
|
return Pirep::with('acars')->where([
|
|
|
|
'state' => PirepState::IN_PROGRESS
|
|
|
|
]);
|
|
|
|
}
|
2017-12-26 05:19:34 +08:00
|
|
|
}
|