$model = $this->getModelInstance();
}
foreach ($model->getFields() as $field) {
- if (isset($this->_fields[$field->getAttribute('name')])) {
- continue;
+ try {
+ if (isset($this->_fields[$field->getAttribute('name')])) {
+ continue;
+ }
+ $this->addField($field);
+ }catch (\Error $e){
+ dd($field,$e);
}
- $this->addField($field);
}
}
$res = $this->getMedia($c);
if ($res->count() === 0 && $this->hasField($c)) {
$c = $this->getAttribute($c);
+ if(null===$c){
+ return [];
+ }
$res = $this->getMedia($c);
}
return $res;
public function getFirstMediaInField(string $fieldName): ?Media
{
$collection = $this->getMediaInField($fieldName);
+ if(!$collection){
+ return null;
+ }
if ($collection->count() > 0) {
return $collection->first();
}