Bảng customers chỉ có cột address nên address_1/address_2 từ form admin bị bỏ khi validate. Thêm cột address_2, fillable, rule validate và trả đủ field địa chỉ trong CustomerResource. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
36 lines
1.2 KiB
PHP
36 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Api\Admin;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class CustomerResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'uuid' => $this->uuid,
|
|
'fullname' => $this->fullname,
|
|
'email' => $this->email,
|
|
'phone' => $this->phone,
|
|
'company' => $this->company,
|
|
'address' => $this->address,
|
|
'address_2' => $this->address_2,
|
|
'city' => $this->city,
|
|
'state' => $this->state,
|
|
'postcode' => $this->postcode === null ? null : (string) $this->postcode,
|
|
'country' => $this->country,
|
|
'note' => $this->note,
|
|
'status' => (int) $this->status,
|
|
'total' => (int) $this->total,
|
|
'email_marketing' => (bool) $this->email_marketing,
|
|
'receive_deposit' => (bool) $this->receive_deposit,
|
|
'created_at' => $this->created_at,
|
|
'is_starred' => (bool) $this->is_starred,
|
|
'tags' => $this->whenLoaded('tags'),
|
|
];
|
|
}
|
|
}
|