public function index($token) { if ($token === 'W2Xcoiq28sLNasiszA819qgLk42CTc5b') { $addressees = Model::all(); $news = News::getForDelivery(); $tenders = Tender::getForDelivery(); $vacancies = Vacancy::getForDelivery(); $shares = Share::getForDelivery(); $expert_advices = ExpertAdvice::getForDelivery(); foreach ($addressees as $addressee) { $params['title'] = $addressee->locale . '_title'; $params['text'] = $addressee->locale . '_text'; $params['locale'] = $addressee->locale; $addressee->news && count($news) ? $params['delivery']['news'] = $news : null; $addressee->tenders && count($tenders) ? $params['delivery']['tenders'] = $tenders : null; $addressee->vacancies && count($vacancies) ? $params['delivery']['vacancies'] = $vacancies : null; $addressee->shares && count($shares) ? $params['delivery']['shares'] = $shares : null; $addressee->expert_advices && count($expert_advices) ? $params['delivery']['expert_advices'] = $expert_advices : null; if (isset($params['delivery'])) { Mail::send('emails.delivery', $params, function ($message) use($addressee) { $from_address = MailConfig::first(); $from_name = Config::get('mail.from'); $message->from($from_address->feedback_mail, $from_name['name']); $message->to($addressee->email)->subject(trans('front-end' . DS . 'emails' . DS . 'delivery.subject')); }); } unset($params); } News::where('sended', 0)->update(['sended' => 1]); Tender::where('sended', 0)->update(['sended' => 1]); Vacancy::where('sended', 0)->update(['sended' => 1]); Share::where('sended', 0)->update(['sended' => 1]); ExpertAdvice::where('sended', 0)->update(['sended' => 1]); } }
if (!$Page->save()) { $result = false; } } } if ($result) { $this->setMessage('pages テーブルの更新に成功しました。'); } else { $this->setMessage('pages テーブルの更新に失敗しました。', true); } /** * site_configs 更新 */ App::import('Model', 'SiteConfig'); App::import('Model', 'Mail.MailConfig'); $MailConfig = new MailConfig(); $mailConfig = $MailConfig->read(null, 1); $SiteConfig = new SiteConfig(); $siteConfig = $SiteConfig->findExpanded(); $siteConfig['mail_encode'] = 'ISO-2022-JP'; if ($mailConfig) { $siteConfig['smtp_host'] = $mailConfig['MailConfig']['smtp_host']; $siteConfig['smtp_user'] = $mailConfig['MailConfig']['smtp_username']; $siteConfig['smtp_password'] = $mailConfig['MailConfig']['smtp_password']; } else { $siteConfig['smtp_host'] = ''; $siteConfig['smtp_user'] = ''; $siteConfig['smtp_password'] = ''; } $siteConfig['formal_name'] = $siteConfig['name']; if ($SiteConfig->saveKeyValue($siteConfig)) {