Skip to content

Commit

Permalink
fixed prefixedValue
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to committed Dec 2, 2022
1 parent c9aef2f commit af2ba8a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/Resources/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Validator;
use Leeto\MoonShine\Actions\Action;
use Leeto\MoonShine\Actions\FiltersAction;
use Leeto\MoonShine\Contracts\Actions\ActionContract;
use Leeto\MoonShine\Contracts\HtmlViewable;
use Leeto\MoonShine\Contracts\Resources\ResourceContract;
Expand Down Expand Up @@ -240,10 +241,23 @@ public function getActions(): Collection
{
$actions = collect();

$hasFilters = false;

foreach ($this->actions() as $action) {
if($action instanceof FiltersAction) {
$hasFilters = true;
}

$actions->add($action->setResource($this));
}

if(!$hasFilters && !empty($this->filters())) {
$actions->add(
FiltersAction::make(trans('moonshine::ui.filters'))
->setResource($this)
);
}

return $actions;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Traits/Fields/FileTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ public function formViewValue(Model $item): mixed
return $this->prefixedValue($item->{$this->field()});
}

protected function prefixedValue(string $value): string
protected function prefixedValue(?string $value): string
{
return ltrim($value, $this->withPrefix);
return $value ? ltrim($value, $this->withPrefix) : '';
}

public function exportViewValue(Model $item): string
Expand Down

0 comments on commit af2ba8a

Please sign in to comment.