Skip to content

Commit

Permalink
feat: 处理因为class不存在导致的异常
Browse files Browse the repository at this point in the history
  • Loading branch information
slowlyo committed Sep 9, 2024
1 parent 8d62124 commit 07d3ac0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Models/AdminApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class AdminApi extends BaseModel
public function templateTitle(): Attribute
{
return Attribute::get(function () {
if (!(new \ReflectionClass($this->template))->isSubclassOf(AdminBaseApi::class)) {
return '';
}
if (!class_exists($this->template)) return '';

if (!(new \ReflectionClass($this->template))->isSubclassOf(AdminBaseApi::class)) return '';

$api = app($this->template);

Expand All @@ -34,9 +34,9 @@ public function templateTitle(): Attribute
public function method(): Attribute
{
return Attribute::get(function () {
if (!(new \ReflectionClass($this->template))->isSubclassOf(AdminBaseApi::class)) {
return 'any';
}
if (!class_exists($this->template)) return '';

if (!(new \ReflectionClass($this->template))->isSubclassOf(AdminBaseApi::class)) return 'any';

$method = app($this->template)->getMethod();

Expand Down
2 changes: 2 additions & 0 deletions src/Models/AdminRelationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public function method(): Attribute

public function buildArgs()
{
if(!class_exists($this->model)) return [];

$reflection = new \ReflectionClass($this->model);
$params = $reflection->getMethod($this->method)->getParameters();

Expand Down

0 comments on commit 07d3ac0

Please sign in to comment.