From 81d2d7dd0e2701d053828e4e86ef11575ac30ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Mon, 4 Mar 2024 10:33:56 +0100 Subject: [PATCH] getting started with filters --- composer.json | 2 +- src/Bazar.php | 2 +- src/Models/Address.php | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 00cdf9f8..cbd57e15 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ }, "require": { "php": "^8.2 || ^8.3", - "conedevelopment/root": "^2.0.0" + "conedevelopment/root": "^2.1.0" }, "require-dev": { "fakerphp/faker": "^1.9.1", diff --git a/src/Bazar.php b/src/Bazar.php index a0f5b3dc..4ec8790a 100644 --- a/src/Bazar.php +++ b/src/Bazar.php @@ -12,7 +12,7 @@ abstract class Bazar * * @var string */ - public const VERSION = '1.0.0'; + public const VERSION = '1.0.1'; /** * The currency in use. diff --git a/src/Models/Address.php b/src/Models/Address.php index 921ed4f0..b0ebcea5 100644 --- a/src/Models/Address.php +++ b/src/Models/Address.php @@ -5,6 +5,7 @@ use Closure; use Cone\Bazar\Database\Factories\AddressFactory; use Cone\Bazar\Interfaces\Models\Address as Contract; +use Cone\Root\Support\Filters; use Cone\Root\Traits\InteractsWithProxy; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\Factory; @@ -143,7 +144,11 @@ protected function alias(): Attribute { return new Attribute( get: function (?string $value): ?string { - return $this->exists ? ($value ?: "#{$this->getKey()}") : $value; + return Filters::apply( + 'bazar:address.alias_attribute', + $this->exists ? ($value ?: "#{$this->getKey()}") : $value, + $this + ); } ); } @@ -156,8 +161,12 @@ protected function alias(): Attribute protected function name(): Attribute { return new Attribute( - get: static function (mixed $value, array $attributes): string { - return trim(sprintf('%s %s', $attributes['first_name'], $attributes['last_name'])); + get: function (mixed $value, array $attributes): string { + return Filters::apply( + 'bazar:address.name_attribute', + trim(sprintf('%s %s', $attributes['first_name'], $attributes['last_name'])), + $this + ); } ); }