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