param = $param; } public function build() { try { $params = $this->param; $mailSenderAddress = Config::get('app.mailSenderAddress'); $propertyService = App::make('App\Core\Service\PropertyService'); $propertySelectCriteria = [ 'criteria' => [ ['field' => 'id', 'condition' => '=', 'value' => $params['propertyId']], ], 'with' => ['userPropertyMapping.user'], 'firstRow' => true ]; $propertyData = $propertyService->select($propertySelectCriteria); if($propertyData['status'] == 'success') { $userPropertyMappingCollect = collect($propertyData['data']['user_property_mapping']); $userPropertyMapping = $userPropertyMappingCollect->where('status',1)->where('user.status',1)->sortBy('id'); $userPropertyMapping = $userPropertyMapping ? $userPropertyMapping->toArray() : []; $defaultUser = reset($userPropertyMapping); $mailData['to'] = [ 'email' => $defaultUser['user']['email'], 'nameSurname' => $defaultUser['user']['nameSurname'], ]; $mailData['bcc'] = []; foreach ($userPropertyMapping as $user) { //$mailData['bcc'][] = $user['user']['email']; } $mailData['bcc'] = 'channel@extranetwork.com';//TODO: Delete $mailParams= [ 'email' => $mailData['to']['email'], 'nameSurname' => $mailData['to']['nameSurname'], 'propertyName' => $propertyData['data']['name'], ]; $mailTitle = 'Rezervasyonlarını ikiye katlamaya hazır mısın? 🚀'; //app('translator')->setLocale('en'); //echo view('emails.reminder.trialFirstMail', compact('mailParams')); die(); return $this->from($mailSenderAddress, 'Extranetwork') ->view('emails.reminder.trialFirstMail', compact('mailParams')) ->to($mailData['to']['email'], $mailData['to']['nameSurname']) ->bcc($mailData['bcc']) ->subject($mailTitle) ->with(['message' => $this]); } } catch (ApiErrorException $e) { return output(['status' => -1, 'message' => $e->getMessage()]); } catch (Exception $e) { $message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage(); Log::error($message); return output(['status' => -1, 'message' => $e->getMessage()]); } } }