Skip to content

Commit 09e312b

Browse files
committed
Code formatted by using pint
1 parent 9814e1c commit 09e312b

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "balajidharma/laravel-attributes",
3-
"description": "Laravel form builder",
3+
"description": "A flexible attribute management system for Laravel models",
44
"license": "MIT",
55
"keywords": ["attributes","laravel","laravel-attributes","laravel-attribute","laravel-framework"],
66
"authors": [

config/attributes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
['name' => 'date', 'validation' => 'date', 'cast' => 'date'],
2020
['name' => 'json', 'validation' => 'json', 'cast' => 'array'],
2121
],
22-
];
22+
];

src/Exceptions/AttributeValueException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ public static function invalidValue($message)
1010
{
1111
return new static($message);
1212
}
13-
}
13+
}

src/Models/Attribute.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Illuminate\Support\Facades\Config;
99
use Illuminate\Support\Facades\Validator;
1010

11-
1211
class Attribute extends Model
1312
{
1413
protected $appends = ['data'];
@@ -19,7 +18,7 @@ class Attribute extends Model
1918
'value',
2019
'weight',
2120
'attributable_id',
22-
'attributable_type'
21+
'attributable_type',
2322
];
2423

2524
public function __construct(array $attributes = [])
@@ -45,19 +44,19 @@ protected function data(): CastsAttribute
4544
get: function (mixed $value, array $attributes) {
4645
$dataType = collect(Config::get('attributes.data_types'))->firstWhere('name', $attributes['data_type']);
4746
$this->casts['data'] = $dataType['cast'];
47+
4848
return $this->castAttribute('data', $attributes['value']);
4949
}
5050
);
5151
}
5252

5353
public function setValueAttribute($value)
5454
{
55-
if(Config::get('attributes.validate_value_before_save'))
56-
{
55+
if (Config::get('attributes.validate_value_before_save')) {
5756
$dataType = collect(Config::get('attributes.data_types'))->firstWhere('name', $this->data_type);
5857

5958
$validator = Validator::make(['value' => $value], [
60-
'value' => $dataType['validation']
59+
'value' => $dataType['validation'],
6160
]);
6261

6362
if ($validator->fails()) {
@@ -67,4 +66,4 @@ public function setValueAttribute($value)
6766

6867
$this->attributes['value'] = $value;
6968
}
70-
}
69+
}

src/Traits/HasAttributable.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ public function attributes(): MorphMany
2323
* Attach a single attribute.
2424
*/
2525
public function attachAttribute(
26-
string $name,
27-
string $value,
28-
?string $data_type = 'string',
26+
string $name,
27+
string $value,
28+
?string $data_type = 'string',
2929
?int $weight = 0
3030
): Model {
3131
return $this->attributes()->create([
@@ -86,13 +86,13 @@ public function hasAttributeDataType(string $dataType): bool
8686
->exists();
8787
}
8888

89-
9089
/**
9190
* Delete all attributes.
9291
*/
9392
public function deleteAllAttributes(): self
9493
{
9594
$this->getAttributeQuery()->delete();
95+
9696
return $this;
9797
}
9898

0 commit comments

Comments
 (0)