Skip to content

Commit

Permalink
getting started with filters
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Mar 4, 2024
1 parent 218dc44 commit 81d2d7d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/Bazar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 12 additions & 3 deletions src/Models/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
);
}
);
}
Expand All @@ -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
);
}
);
}
Expand Down

0 comments on commit 81d2d7d

Please sign in to comment.