Example #1
0
 public function findInactiveArticles(Request $request)
 {
     $desde = date_format(date_create($request->fechaDesde), "Y/m/d H:i:s");
     $hasta = date_format(date_create($request->fechaHasta), "Y/m/d 23:59:99");
     $inactivos = 0;
     $active = Movement::select('article_id')->distinct()->where('created_at', '>', $desde)->where('created_at', '<', $hasta)->get();
     $activos = $active->count();
     $articles = Article::whereNotIn('id', $active)->get();
     //        dd($articles);
     foreach ($articles as $article) {
         $inactivos++;
         $article->update(['active' => 0]);
         //            dd($article);
     }
     return view('settings.findInactiveArticles', compact('activos', 'inactivos'));
 }