ldc-legaulois/app/Http/Resources/CustomerCrmResource.php
Jérémy Munsch bc7140f945 phpcs Fixes
2021-06-14 15:15:52 +02:00

40 lines
1.1 KiB
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Models\Customers;
class CustomerCrmResource extends JsonResource
{
/** @var Customer */
private $customer;
public function __construct(Customers $customer)
{
$this->customer = $customer;
}
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
public function toArray($request)
{
$crmCustomer = (object)$this->customer->apiData;
return [
'crm_id' => $this->customer->crm_id,
'firstname' => $crmCustomer->firstname,
'lastname' => $crmCustomer->lastname,
'optin' => null,
'birthdate' => null,
'phone' => $crmCustomer->phone,
'address' => $crmCustomer->address,
'address2' => null,
'city' => $crmCustomer->city,
'postcode' => $crmCustomer->postcode
];
}
}