Files
InvoiceShelf/app/Domains/Contacts/Http/Requests/CustomerPortal/CustomerProfileRequest.php
T
Darko Gjorgjijoski 5ef7804e60 refactor: adopt modular domain architecture (#747)
* refactor: stabilize model identities for domain migration

* refactor: extract module platform context

* refactor: assign models to domain contexts

* refactor: extract ai platform context

* refactor: extract storage platform context

* refactor: extract mail platform context

* refactor: extract pdf platform context

* refactor: extract operations platform context

* refactor: move installation into operations platform

* refactor: extract money domain context

* refactor: extract taxation domain context

* refactor: extract catalog domain context

* refactor: extract metadata domain context

* refactor: extract reporting domain context

* refactor: extract purchases domain context

* refactor: extract receivables domain context

* refactor: extract accounts domain context

* refactor: complete reporting statement boundary

* refactor: extract contacts domain context

* refactor: extract sales domain context

* refactor: remove legacy application layers

* fix: migrate legacy bouncer role identities
2026-08-05 17:40:03 +02:00

144 lines
3.5 KiB
PHP

<?php
namespace App\Domains\Contacts\Http\Requests\CustomerPortal;
use App\Domains\Contacts\Models\Address;
use App\Rules\IdnEmail;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;
class CustomerProfileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'name' => [
'nullable',
],
'password' => [
'nullable',
'min:8',
],
'email' => [
'nullable',
new IdnEmail,
Rule::unique('customers')->where('company_id', $this->header('company'))->ignore(Auth::id(), 'id'),
],
'billing.name' => [
'nullable',
],
'billing.address_street_1' => [
'nullable',
],
'billing.address_street_2' => [
'nullable',
],
'billing.city' => [
'nullable',
],
'billing.state' => [
'nullable',
],
'billing.country_id' => [
'nullable',
],
'billing.zip' => [
'nullable',
],
'billing.phone' => [
'nullable',
],
'billing.fax' => [
'nullable',
],
'shipping.name' => [
'nullable',
],
'shipping.address_street_1' => [
'nullable',
],
'shipping.address_street_2' => [
'nullable',
],
'shipping.city' => [
'nullable',
],
'shipping.state' => [
'nullable',
],
'shipping.country_id' => [
'nullable',
],
'shipping.zip' => [
'nullable',
],
'shipping.phone' => [
'nullable',
],
'shipping.fax' => [
'nullable',
],
'customer_avatar' => [
'nullable',
'file',
'mimes:gif,jpg,png',
'max:20000',
],
'is_customer_avatar_removed' => [
'nullable',
'boolean',
],
];
}
/** @return array<string, mixed> */
public function customerAttributes(): array
{
return $this->safe()->only(['name', 'email', 'password']);
}
/** @return array<string, mixed>|null */
public function shippingAddress(): ?array
{
$address = $this->input('shipping');
if (! is_array($address)) {
return null;
}
return collect($address)
->merge([
'type' => Address::SHIPPING_TYPE,
])
->toArray();
}
/** @return array<string, mixed>|null */
public function billingAddress(): ?array
{
$address = $this->input('billing');
if (! is_array($address)) {
return null;
}
return collect($address)
->merge([
'type' => Address::BILLING_TYPE,
])
->toArray();
}
}