fix:trim whitespace from form fields
This commit is contained in:
@@ -3,14 +3,21 @@
|
||||
namespace App\Actions\Fortify;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\WithTrimStrings;
|
||||
use Laravel\Jetstream\Jetstream;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Laravel\Fortify\Contracts\CreatesNewUsers;
|
||||
use Laravel\Jetstream\Jetstream;
|
||||
|
||||
class CreateNewUser implements CreatesNewUsers
|
||||
{
|
||||
use PasswordValidationRules;
|
||||
use WithTrimStrings;
|
||||
|
||||
public function trimExceptions()
|
||||
{
|
||||
return ['password'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and create a newly registered user.
|
||||
|
||||
@@ -3,13 +3,16 @@
|
||||
namespace App\Actions\Fortify;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Traits\WithTrimStrings;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
|
||||
|
||||
class UpdateUserProfileInformation implements UpdatesUserProfileInformation
|
||||
{
|
||||
use WithTrimStrings;
|
||||
|
||||
/**
|
||||
* Validate and update the given user's profile information.
|
||||
*
|
||||
|
||||
@@ -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),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use App\Models\Portfolio;
|
||||
use App\Models\User;
|
||||
use App\Traits\WithTrimStrings;
|
||||
use Livewire\Attributes\Rule;
|
||||
use Livewire\Volt\Component;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -11,6 +12,7 @@ use App\Notifications\InvitedOnboardingNotification;
|
||||
new class extends Component {
|
||||
|
||||
use Toast;
|
||||
use WithTrimStrings;
|
||||
|
||||
// props
|
||||
public ?Portfolio $portfolio = null;
|
||||
@@ -126,7 +128,7 @@ new class extends Component {
|
||||
</label>
|
||||
|
||||
<div class="border-primary border rounded-sm px-2 py-5 mb-2 max-h-[20rem] overflow-y-scroll">
|
||||
@if ($portfolio->owner)
|
||||
@if ($portfolio?->owner)
|
||||
<x-list-item
|
||||
:item="$portfolio->owner"
|
||||
avatar="profile_photo_url"
|
||||
@@ -148,7 +150,7 @@ new class extends Component {
|
||||
</x-list-item>
|
||||
@endif
|
||||
|
||||
@foreach (collect($this->portfolio?->users)->where('pivot.owner', '!=', 1) as $user)
|
||||
@foreach (collect($portfolio?->users)->where('pivot.owner', '!=', 1) as $user)
|
||||
<x-list-item
|
||||
:item="$user"
|
||||
avatar="profile_photo_url"
|
||||
@@ -220,6 +222,7 @@ new class extends Component {
|
||||
icon="o-envelope"
|
||||
placeholder="{{ __('Type an email address to share portfolio') }}"
|
||||
wire:model="emailAddress"
|
||||
type="email"
|
||||
required
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user