/**
  * @param            $userId
  * @param Blueprint  $blueprint
  * @param Collection $collection
  *
  * @return $this
  */
 public function uploads($userId, Blueprint $blueprint, Collection $collection)
 {
     $allBlueprints = $blueprint->where(['user_id' => $userId])->with('mods')->select('id', 'name', 'author_name', 'bc_version', 'version', 'screenshot', 'survival_creative', 'sizeX', 'sizeY', 'sizeZ', 'description', 'uploaded_at')->orderBy('uploaded_at', 'desc')->paginate(4);
     $collections = $collection->where(['user_id' => $userId])->select('id', 'name')->get()->toArray();
     if (!$allBlueprints->isEmpty()) {
         return view('buildcraft.user.uploads')->with(['allBlueprints' => $allBlueprints, 'user_id' => $userId, 'collections' => $collections]);
     }
     return view('buildcraft.user.uploads')->with(['noUploads' => true]);
 }
 /**
  * Sweet baby jesus hashtag2
  *
  * @param                     $userId
  * @param                     $blueprintId
  * @param PathBuilder         $pathBuilder
  * @param Blueprint           $blueprintModel
  * @param BlueprintCollection $blueprintCollection
  * @param Filesystem          $file
  * @param Repository          $repository
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postDeleteBlueprint($userId, $blueprintId, PathBuilder $pathBuilder, Blueprint $blueprintModel, BlueprintCollection $blueprintCollection, Filesystem $file, Repository $repository)
 {
     $blueprint = $blueprintModel->where(['id' => $blueprintId])->first()->toArray();
     $blueprintScreenshootRequired = $pathBuilder->create()->fromPublicPath($repository->get('blueprint.paths.storage.buildcraft.images')) . $blueprint['screenshot'];
     // append the archive name name to the default storage path
     $blueprintArchive = $pathBuilder->create()->fromPublicPath($repository->get('blueprint.paths.storage.buildcraft.archives')) . $blueprint['archive_name'];
     // append the screenshoot name to the default storage path
     if ($file->exists($blueprintScreenshootRequired)) {
         $file->delete($blueprintScreenshootRequired);
     }
     if ($file->exists($blueprintArchive)) {
         $file->delete($blueprintArchive);
     }
     if (null !== $blueprint['screenshot_optional_0']) {
         $blueprintScreenshootOptiona_0 = $pathBuilder->create()->fromPublicPath($repository->get('blueprint.paths.storage.buildcraft.images')) . $blueprint['screenshot_optional_0'];
         // append the screenshoot name to the default storage path
         if ($file->exists($blueprintScreenshootOptiona_0)) {
             $file->delete($blueprintScreenshootOptiona_0);
         }
     }
     if (null !== $blueprint['screenshot_optional_1']) {
         $blueprintScreenshootOptiona_1 = $pathBuilder->create()->fromPublicPath($repository->get('blueprint.paths.storage.buildcraft.images')) . $blueprint['screenshot_optional_1'];
         // append the screenshoot name to the default storage path
         if ($file->exists($blueprintScreenshootOptiona_1)) {
             $file->delete($blueprintScreenshootOptiona_1);
         }
     }
     // Delete any association of this blueprint with any collection
     $blueprintCollection->where(['blueprint_id' => $blueprintId])->delete();
     if ($blueprintModel->destroy($blueprintId)) {
         return redirect()->route('buildcraft::user::uploads', ['user_id' => $userId])->with('blueprintDeleteSuccess', true);
     }
     return redirect()->route('buildcraft::user::uploads', ['user_id' => $userId])->with('blueprintDeleteSuccess', false);
 }
 /**
  * @param            $userId
  * @param Blueprint  $blueprint
  * @param Collection $collection
  *
  * @return $this|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function getProfile($userId, Blueprint $blueprint, Collection $collection)
 {
     $latestUpload = $blueprint->where('user_id', $userId)->select(['id', 'screenshot'])->orderBy('uploaded_at', 'desc')->limit(4)->get();
     $blueprintCollections = $collection->where('user_id', $userId)->get();
     if (!$latestUpload->isEmpty()) {
         return view('general.user.profile')->with(['latestUpload' => $latestUpload->toArray(), 'userId' => $userId, 'blueprintCollections' => $blueprintCollections->toArray()]);
     }
     return view('general.user.profile')->with('userId', $userId);
 }