fix:trim whitespace from form fields

This commit is contained in:
hackerESQ
2024-10-29 12:38:05 -05:00
parent 07ebdaf77f
commit 863627bb42
4 changed files with 40 additions and 5 deletions
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace App\Traits;
use Illuminate\Support\Str;
trait WithTrimStrings
{
public function trimExceptions(): array
{
return [];
}
public function updatedWithTrimStrings(string $property, mixed $value): void
{
if (is_string($value) && !in_array($property, $this->trimExceptions())) {
$this->fill([
$property => Str::trim($value),
]);
}
}
}