Skip to content

Commit 650da77

Browse files
committed
If listview index return a collection (usually a one-to-many relation) show count instead
1 parent 6f944fd commit 650da77

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Controllers/BaseController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App;
66
use App\Http\Controllers\Controller;
77
use Auth;
8+
use Illuminate\Database\Eloquent\Collection;
89
use Illuminate\Support\Facades\View;
910
use Illuminate\Support\Str;
1011
use Route;
@@ -275,6 +276,9 @@ public function listviewRow($row)
275276
break;
276277
}
277278
}
279+
if ($value instanceof Collection) {
280+
$value = $value->count() ?: '';
281+
}
278282
$response .= '<span>' . htmlspecialchars($value) . '</span>';
279283
}
280284
}

0 commit comments

Comments
 (0)