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]); } }