civility = (isset($edition['civility'])) ? CivilityEnum::make(intval($edition['civility']))->label() : null; $this->first_name = $edition['first_name'] ?? null; $this->last_name = $edition['last_name'] ?? null; $this->society = $edition['society'] ?? null; $this->email = $edition['email']; $this->phone = $edition['phone'] ?? null; $this->address = $edition['address'] ?? null; $this->postal_code = $edition['postal_code'] ?? null; $this->city = $edition['city'] ?? null; $this->object = (isset($edition['object'])) ? ObjectEnum::make(intval($edition['object']))->label() : null; $this->product_name = $edition['product_name']; $this->product_date_limit = $edition['product_date_limit']; $this->product_barcode = $edition['product_barcode']; $this->product_lot = $edition['product_lot']; $this->product_date_consumption = $edition['product_date_consumption']; $this->product_location = $edition['product_location']; $this->message = $edition['message'] ?? null; $this->file = $edition['file'] ?? null; } /** * Build the message. * * @return $this */ public function build() { $mail = $this->subject(\config('app.name') . ' - contact formulaire') ->markdown('emails.send-contact-form') ->with([ 'civility' => $this->civility, 'first_name' => $this->first_name, 'last_name' => $this->last_name, 'society' => $this->society, 'email' => $this->email, 'phone' => $this->phone, 'address' => $this->address, 'postal_code' => $this->postal_code, 'city' => $this->city, 'object' => $this->object, 'product_name' => $this->product_name, 'product_date_limit' => $this->product_date_limit, 'product_barcode' => $this->product_barcode, 'product_lot' => $this->product_lot, 'product_date_consumption' => $this->product_date_consumption, 'product_location' => $this->product_location, 'message' => $this->message, ]); if (isset($this->file)) { $mail = $mail->attach($this->file->getRealPath(), [ 'as' => $this->file->getClientOriginalName(), 'mime' => $this->file->getClientMimeType(), ]); } return $mail; } }