public function get(DeltaVCalculator $deltaV) { $objectsToReview = Object::where('status', ObjectPublicationStatus::QueuedStatus)->orderBy('created_at', 'ASC')->with('user', 'tags')->get()->map(function ($objectToReview) use($deltaV) { $objectToReview->deltaV = $deltaV->calculate($objectToReview); return $objectToReview; }); return response()->json($objectsToReview, 200); }
/** * Execute the console command. * * @return mixed */ public function handle() { $orphanedObjects = Object::where('status', ObjectPublicationStatus::NewStatus)->where('created_at', '<', Carbon::now()->subWeek())->get(); $trashedObjectsByKey = $orphanedObjects->each(function ($orphanedObject) { $orphanedObject->deleteFromTemporary(); })->keyBy('object_id'); Object::destroy($trashedObjectsByKey->keys()); }
public function index() { $publishers = Publisher::with('objects')->get()->map(function ($publisher) { $publisher->articleCount = $publisher->objects->count(); $publisher->mostRecentArticle = $publisher->objects->sortByDesc('originated_at')->first(); unset($publisher->objects); return $publisher; }); JavaScript::put(['publishers' => $publishers, 'articleCount' => Object::where('type', MissionControlType::Article)->inMissionControl()->count()]); return view('missionControl.publishers.index'); }
public function get($year, $month) { $newsSummary = Object::where('subtype', MissionControlSubtype::NewsSummary)->whereRaw('YEAR(originated_at) = :year WHERE MONTH(originated_at) = :month', ['year' => $year, 'month' => $month])->firstOrFail(); return view('newsSummary', ['newsSummary' => $newsSummary, 'year' => $year, 'month' => Carbon::createFromFormat($month, 'm')->format('F')]); }
public function aboutTotalData() { return response()->json(['size' => round(Object::inMissionControl()->sum('size') / 1000000000, 1) . ' GB', 'images' => Object::where('type', MissionControlType::Image)->count(), 'videos' => Object::where('type', MissionControlType::Video)->count(), 'documents' => Object::where('type', MissionControlType::Document)->count()]); }