Skip to content

Commit

Permalink
fix statue activity log (#396)
Browse files Browse the repository at this point in the history
* fix statue activity log

* formatting

---------

Co-authored-by: Andrei Ioniță <[email protected]>
  • Loading branch information
gheorghelupu17 and andreiio authored Sep 2, 2024
1 parent 77d88d5 commit 99559ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use App\Filament\Forms\Components\Value;
use App\Models\Activity;
use Filament\Tables\Actions\ViewAction as BaseAction;
use Illuminate\Support\HtmlString;
use Spatie\MediaLibrary\MediaCollections\Models\Media;

class ViewActivityAction extends BaseAction
{
Expand Down Expand Up @@ -41,6 +43,22 @@ protected function setUp(): void

Value::make('changed_field_new_value')
->label(__('activity.value.new'))
->content(function (Activity $record) {
if ($record->changed_field === 'statute') {
$media = Media::find($record->changed_field_new_value);
if (! $media) {
return '-';
}

return new HtmlString(\sprintf(
'<a href="%s" target="_blank">%s</a>',
$media->getTemporaryUrl(now()->addMinutes(30)),
$media->file_name
));
}

return $record->changed_field_new_value;
})
->inlineLabel(),
]);

Expand Down
4 changes: 0 additions & 4 deletions app/Models/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,6 @@ public function reject(?string $reason): void
*/
public function getModifiedField(mixed $value): ?string
{
if ($this->description === 'statute') {
$value = Media::find($value)?->getUrl();
}

if (\gettype($value) == 'boolean') {
$value = $value ? __('field.boolean.true') : __('field.boolean.false');
}
Expand Down

0 comments on commit 99559ba

Please sign in to comment.