Fix behavior on automatic resource name setter
This commit is contained in:
parent
8dcab927e5
commit
faaf27632c
1 changed files with 9 additions and 0 deletions
|
@ -39,6 +39,15 @@ class Fractal extends SpatieFractal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_null($this->resourceName) && $this->data instanceof LengthAwarePaginator) {
|
||||||
|
$item = collect($this->data->items())->first();
|
||||||
|
if ($item instanceof Model) {
|
||||||
|
if (defined(get_class($item) . '::RESOURCE_NAME')) {
|
||||||
|
$this->resourceName = constant(get_class($item) . '::RESOURCE_NAME');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return parent::createData();
|
return parent::createData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue