Skip to content

Commit 29cbaf2

Browse files
authored
Exception: "TypeError"
The input parameter of the applyScopes() function can be of type Relation and the returned value can also be of type Relation.
1 parent f8b9a49 commit 29cbaf2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Services/DataTable.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Yajra\DataTables\QueryDataTable;
2323
use Yajra\DataTables\Transformers\DataArrayTransformer;
2424
use Yajra\DataTables\Utilities\Request;
25+
use Illuminate\Database\Eloquent\Relations\Relation as EloquentRelation;
2526

2627
abstract class DataTable implements DataTableButtons
2728
{
@@ -243,7 +244,7 @@ public function ajax(): JsonResponse
243244
{
244245
$query = null;
245246
if (method_exists($this, 'query')) {
246-
/** @var EloquentBuilder|QueryBuilder $query */
247+
/** @var EloquentBuilder|QueryBuilder|EloquentRelation $query */
247248
$query = app()->call([$this, 'query']);
248249
$query = $this->applyScopes($query);
249250
}
@@ -713,10 +714,10 @@ public function __get(string $key)
713714
/**
714715
* Apply query scopes.
715716
*
716-
* @param EloquentBuilder|QueryBuilder $query
717-
* @return EloquentBuilder|QueryBuilder
717+
* @param EloquentBuilder|QueryBuilder|EloquentRelation $query
718+
* @return EloquentBuilder|QueryBuilder|EloquentRelation
718719
*/
719-
protected function applyScopes(EloquentBuilder|QueryBuilder $query): EloquentBuilder|QueryBuilder
720+
protected function applyScopes(EloquentBuilder|QueryBuilder|EloquentRelation $query): EloquentBuilder|QueryBuilder|EloquentRelation
720721
{
721722
foreach ($this->scopes as $scope) {
722723
$scope->apply($query);

0 commit comments

Comments
 (0)