Skip to content

Commit

Permalink
Fix media type setting's logical problem
Browse files Browse the repository at this point in the history
  • Loading branch information
darron1217 committed Apr 19, 2018
1 parent 1eacf7a commit c16858e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Modules/Setting/Entities/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class Setting extends Model
protected $fillable = ['name', 'value', 'description', 'isTranslatable', 'plainValue'];
protected $table = 'setting__settings';

public function hasMedia(): bool
public function isMedia(): bool
{
$value = json_decode($this->plainValue, true);
return is_array($value) && isset($value['media_single']) && $setting->files->count();
return is_array($value) && isset($value['media_single']);
}
}
2 changes: 1 addition & 1 deletion Modules/Setting/Support/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function get($name, $locale = null, $default = null)
return is_null($default) ? $defaultFromConfig : $default;
}

if($setting->hasMedia() && $media = $setting->files->first()) {
if($setting->isMedia() && $media = $setting->files()->first()) {
return $media->path;
}

Expand Down

0 comments on commit c16858e

Please sign in to comment.