Skip to content

Commit

Permalink
show easy to understand error messages on morph to, show name instead…
Browse files Browse the repository at this point in the history
… of Person #1 or something like that
  • Loading branch information
skalero01 committed Apr 10, 2020
1 parent e9e207e commit cf55551
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Inputs/MorphTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,20 @@ public function getValue($object)
return '--';
}
$class = get_class($value);
if(!isset($this->types_models)) {
abort(405, 'Please defines the possible types for the polimorfic values of '.$this->column.' with types() function');
}
$result = $this->types_models->search($class);
if(!isset($result)) {
return '--';
}
$front = $this->getFrontOnClass($class);
if(is_null($front)) {
abort(405, $class.' front is not defined on the types');
}
$this->link = $front->base_url.'/'.$value->getKey();
return $result.' #'.$value->getKey();
$title_field = $front->title;
return $value->$title_field;
}

public function form()
Expand Down

0 comments on commit cf55551

Please sign in to comment.