Skip to content

Commit e636a1c

Browse files
authored
Merge pull request #9 from Oliver-Holz/fixes-php-8-get-method-error
fixes issue with php 8 and get_class_methods() on null
2 parents 9b11874 + 6d68883 commit e636a1c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Support/PersistResource.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ public function getValidationAttributes()
147147
foreach ($resource as $field => $rules) {
148148
if ($this->hasRelation($key)) {
149149
$relation = $this->getRelation($key)->type;
150-
} elseif (method_exists($this->object, $key)) {
150+
} elseif (!is_null($this->object) && method_exists($this->object, $key)) {
151151
$relation = $this->object->$key()->type;
152-
} elseif (method_exists($this->object, Str::studly($key))) {
152+
} elseif (!is_null($this->object) && method_exists($this->object, Str::studly($key))) {
153153
$relation = $this->object->{Str::studly($key)}()->type;
154-
} elseif (method_exists($this->object, lcfirst($key))) {
154+
} elseif (!is_null($this->object) && method_exists($this->object, lcfirst($key))) {
155155
$relation = $this->object->{lcfirst($key)}()->type;
156156
} else {
157157
$relation = 'HasOne';

0 commit comments

Comments
 (0)