2024-10-29 12:38:05 -05:00
|
|
|
<?php
|
|
|
|
|
|
2025-01-28 17:33:54 -06:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2024-10-29 12:38:05 -05:00
|
|
|
namespace App\Traits;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
|
|
|
|
trait WithTrimStrings
|
|
|
|
|
{
|
|
|
|
|
public function trimExceptions(): array
|
|
|
|
|
{
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function updatedWithTrimStrings(string $property, mixed $value): void
|
|
|
|
|
{
|
2025-01-28 17:14:49 -06:00
|
|
|
if (is_string($value) && ! in_array($property, $this->trimExceptions())) {
|
2024-10-29 12:38:05 -05:00
|
|
|
$this->fill([
|
|
|
|
|
$property => Str::trim($value),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-01-28 17:14:49 -06:00
|
|
|
}
|