*/ protected $fillable = [ 'civility', 'lastname', 'firstname', 'address', 'email', 'postal', 'town', 'phone', 'type', 'message', 'joinFile', 'productName', 'productCode', 'buyPlace', 'lotNumberName', 'limitDateDay', 'limitDateMonth', 'limitDateYear', 'consumptionDateDay', 'consumptionDateMonth', 'consumptionDateYear', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'type' => ContactFormType::class, 'civility' => ContactFormCivility::class, ]; /** * The model's attributes. * * @var array */ protected $attributes = [ 'productName' => '', 'productCode' => '', 'buyPlace' => '', 'lotNumberName' => 0, 'limitDateDay' => '00', 'limitDateMonth' => '00', 'limitDateYear' => '0000', 'consumptionDateDay' => '00', 'consumptionDateMonth' => '00', 'consumptionDateYear' => '0000', ]; public function __construct(array $attributes = [], ?string $filePath = '') { parent::__construct($attributes); $this->joinFile = self::getFileName($filePath ?? ''); } /** * Export the model data to a Formatted Passerelle Data array. * * * Removed * 'EMETTEUR_OBJETDEMANDE' => "objet de la reclamation string", * 'EMETTEUR_OPT_IN' => '', * 'REPONSE_ETAT' => 0, * 'TYPE_REPONSE' => 'mail', */ public function exportToPasserelleDataArray(): array { // * CF PAsserrelle fields .csv return [ // Le Gaulois brand. 'EMETTEUR_MARQUE' => 1, 'EMETTEUR_DATE' => date('Y-m-d'), 'EMETTEUR_HEURE' => date('h:i:s'), 'EMETTEUR_CIVILITE' => $this->civility->value, // Limited at 50 characters. 'EMETTEUR_NOM' => Str::limit($this->lastname, 50, ''), 'EMETTEUR_PRENOM' => $this->firstname, 'EMETTEUR_ADRESSE1' => $this->address, 'EMETTEUR_ADRESSE2' => '', 'EMETTEUR_CP' => $this->postal, 'EMETTEUR_VILLE' => $this->town, 'EMETTEUR_EMAIL' => $this->email, 'EMETTEUR_TELEPHONE' => $this->phone, 'EMETTEUR_PAYS' => 'France', 'EMETTEUR_NOM_PRODUIT' => $this->productName, 'EMETTEUR_EAN13' => $this->productCode, 'EMETTEUR_DATE_LIMITE_CONSO' => sprintf( '%s/%s/%s', $this->limitDateDay ?? '00', $this->limitDateMonth ?? '00', $this->limitDateYear ?? '0000' ), 'EMETTEUR_NUM_LOT' => $this->lotNumberName, 'EMETTEUR_MESSAGE' => $this->message, 'EMETTEUR_PJ' => $this->joinFile, 'DATE_CONSO' => sprintf( '%s/%s/%s', $this->consumptionDateDay ?? '00', $this->consumptionDateMonth ?? '00', $this->consumptionDateYear ?? '0000' ), 'LIEU_ACHAT' => $this->buyPlace, 'EMETTEUR_OBJETDEMANDE' => 3, 'EMETTEUR_OPT_IN' => '', 'REPONSE_ETAT' => 0, 'TYPE_REPONSE' => 'mail', ]; } /** * Get the file name. */ private function getFileName(string $filePath): string { if (! File::exists($filePath)) { return ''; } return sprintf( 'LEGAULOIS_PASS_MESSAGE-PJ-%s.%s', date('YmdHis'), File::extension($filePath) ); } }