Skip to content

Commit ac4a689

Browse files
author
Michael Deck
committed
Tweaks to clean up code and returned data type
1 parent e087db7 commit ac4a689

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Database/Eloquent/FMEloquentBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ class FMEloquentBuilder extends Builder
2323
public function get($columns = ['*'])
2424
{
2525
$records = $this->toBase()->get();
26-
$models = $this->model->createModelsFromRecordSet(collect($records));
26+
$models = $this->model->createModelsFromRecordSet($records);
2727

2828
// If we actually found models we will also eager load any relationships that
2929
// have been specified as needing to be eager loaded, which will solve the
3030
// n+1 query issue for the developers to avoid running a lot of queries.
31-
if (count($models) > 0) {
31+
if ($models->isNotEmpty()) {
3232
$models = $this->eagerLoadRelations($models->all());
3333
} else {
3434
$models = $models->all();

src/Database/Query/FMBaseBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ public function layoutResponse($name): FMBaseBuilder
410410
*/
411411
public function get($columns = ['*'])
412412
{
413-
$records = Arr::get($this->getData(), 'response.data', []);
413+
$records = collect(Arr::get($this->getData(), 'response.data', []));
414414

415415
// filter to only requested columns
416416
if ($columns !== ['*']) {
@@ -583,6 +583,7 @@ public function min($column, $direction = self::ASCEND)
583583
$this->orderBy($column, $direction);
584584
$result = $this->first();
585585
$min = $result['fieldData'][$this->getMappedFieldName($column)];
586+
586587
return $min;
587588
}
588589

0 commit comments

Comments
 (0)