/** * @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]); }
/** * @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); }
public function postDeleteCollection($userId, $collectionId, BlueprintCollection $blueprintCollection, Collection $collection) { $deletePivot = $blueprintCollection->where('collection_id', $collectionId); $deletePivot->delete(); $collection->destroy($collectionId); return redirect()->route('general::user::getProfile', ['user_id' => $userId])->with('collectionDeleteSuccess', true); }