/**
  * @param $id
  * @return mixed
  */
 private function getResourceWithAccess($id)
 {
     // Get the resource
     $resource = Resource::findOrFail($id);
     // Check the access priviledges
     if (!$resource->canAccess($this->user)) {
         App::abort(403);
         return $resource;
     }
     // Check the source is accessible
     if ($resource->isFile() && !file_exists($resource->getFilePath())) {
         App::abort(404);
     }
     return $resource;
 }