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]);
     }
 }
 public function show($id)
 {
     $infoConfig = InfoConfig::first()->toArray();
     $object = Model::find($id);
     if ($object) {
         return view('news', ['objects' => $object, 'type' => 'tenders', 'title' => LANG . '_title', 'description' => LANG . '_description', 'text' => LANG . '_text', 'requirements' => LANG . '_requirements', 'contacts' => LANG . '_contacts', 'infoConfig' => $infoConfig]);
     }
     return redirect(LANG . '/tenders');
 }
 public function show(Request $request)
 {
     if (!$request->has('q')) {
         return redirect('/' . LANG);
     }
     $params = $request->only('q');
     $searchParams = explode(" ", trim($params['q']));
     $productsResults = Product::search($searchParams);
     $portfoliosResults = Portfolio::search($searchParams);
     $newsResults = News::search($searchParams);
     $tendersResults = Tender::search($searchParams);
     $vacanciesResults = Vacancy::search($searchParams);
     $sharesResults = Share::search($searchParams);
     $experEdvicesResults = ExpertAdvice::search($searchParams);
     $count = count($productsResults) + count($portfoliosResults) + count($newsResults) + count($tendersResults) + count($vacanciesResults) + count($sharesResults) + count($experEdvicesResults);
     return view('search', ['products' => $productsResults, 'portfolios' => $portfoliosResults, 'news' => $newsResults, 'tenders' => $tendersResults, 'vacancies' => $vacanciesResults, 'shares' => $sharesResults, 'experEdvices' => $experEdvicesResults, 'count' => $count, 'title' => LANG . '_title', 'description' => LANG . '_description', 'adderss' => LANG . '_adderss', 'type' => 'news']);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $object = Model::find($id);
     if ($object) {
         $object->delete();
     }
     return redirect()->back();
 }
 public function destroyFileKz($id)
 {
     $tender = Tender::find($id);
     if (!is_null($tender->file_kz)) {
         $file_path = $this->upload_dir_kz . '/' . $tender->file_kz;
         if (file_exists($file_path)) {
             unlink($file_path);
             $tender->file_kz = null;
             $tender->save();
         }
     }
     return redirect()->route('edit', ['id' => $tender->id]);
 }
 /**
  * View 'deleted' tenders
  *
  * @param Tender $tender
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function deleted(Tender $tender)
 {
     $data = $tender->deletedTender()->get();
     return view('tender.deleted', ['tender' => $data]);
 }