Fix bug with showing only last selected stop.
This commit is contained in:
parent
11356a84a2
commit
4fa901dc1b
@ -11,6 +11,8 @@ use Nelmio\ApiDocBundle\Annotation\Model;
|
||||
use Swagger\Annotations as SWG;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use function Kadet\Functional\ref;
|
||||
use function Kadet\Functional\Transforms\property;
|
||||
|
||||
/**
|
||||
* Class DeparturesController
|
||||
@ -63,8 +65,8 @@ class DeparturesController extends Controller
|
||||
{
|
||||
$stops = $stops
|
||||
->getManyById($request->query->get('stop'))
|
||||
->flatMap([ $departures, 'getForStop' ])
|
||||
;
|
||||
->flatMap(ref([ $departures, 'getForStop' ]))
|
||||
->sortBy(property('departure'));
|
||||
|
||||
return $this->json($stops->values()->slice(0, (int)$request->query->get('limit', 8)));
|
||||
}
|
||||
|
@ -108,6 +108,11 @@ class Departure implements Fillable
|
||||
$this->scheduled = $scheduled;
|
||||
}
|
||||
|
||||
public function getDeparture(): Carbon
|
||||
{
|
||||
return $this->estimated ?? $this->scheduled;
|
||||
}
|
||||
|
||||
public function getStop(): Stop
|
||||
{
|
||||
return $this->stop;
|
||||
@ -129,4 +134,4 @@ class Departure implements Fillable
|
||||
? $this->getScheduled()->diffInSeconds($this->getEstimated(), false)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user