public function getActions()
 {
     $entities = Unit::where('documentType', '=', 'tv-news-broadcasts')->get();
     if (count($entities) > 0) {
         return View::make('media.preprocess.metadatadescription.pages.actions', compact('entities'));
     }
     return Redirect::to('media/upload')->with('flashNotice', 'You have not uploaded any "tv-news-broadcasts" documents yet');
     $items = Cart::content();
     if (count($items) > 0) {
         $entities = array();
         foreach ($items as $item) {
             if ($entity = $this->repository->find($item['id'])) {
                 if ($entity->documentType != "tv-news-broadcasts") {
                     continue;
                 }
                 $entity['rowid'] = $item['rowid'];
                 array_push($entities, $entity);
             }
         }
         return View::make('media.preprocess.metadatadescription.pages.actions', compact('entities'));
     }
     return Redirect::to('media/browse')->with('flashNotice', 'You have not added any "tv-news-broadcasts" items to your selection yet');
 }
Esempio n. 2
0
 private function userDocTypes()
 {
     // get all projects a user has access to
     $projects = ProjectHandler::getUserProjects(Auth::user());
     $projects = array_column($projects, 'name');
     $types = [];
     $allunits = 0;
     $searchComponent = new MediaSearchComponent();
     // for each project get the document types in it
     foreach ($projects as $key => $project) {
         $docTypes = Unit::distinct('documentType')->where('project', $project)->get()->toArray();
         // skip if there is no data
         if (!empty($docTypes[0])) {
             // for each document type get the number of units
             $types[$project] = [];
             foreach ($docTypes as $key => $type) {
                 $count = Unit::where('project', $project)->where('documentType', $type[0])->count();
                 $allunits += $count;
                 $types[$project][$type[0]] = $count;
             }
         }
     }
     return [$types, $allunits];
 }