ProfileController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\Profile;
  5. use App\User;
  6. use Illuminate\Http\Request;
  7. use App\Models\Item;
  8. use App\Models\Picture;
  9. use Illuminate\Support\Facades\Auth;
  10. class ProfileController extends Controller
  11. {
  12. public function index()
  13. {
  14. $contentContainer = '';
  15. $profile = Profile::where('user_id', Auth::id())->first();
  16. if ($profile) {
  17. $contentContainer = (string)view('userprofile.profile_form', ['profile' => $profile]);
  18. }
  19. return view('userprofile.index', ["contentContainer" => $contentContainer]);
  20. }
  21. public function showAllItems(User $user = null)
  22. {
  23. $user = $user ?: Auth::user();
  24. $userItemsList = Item::where('user_id', '=', $user->id)->get();
  25. if (count($userItemsList) > 0) {
  26. $userItemsList->load('picture');
  27. }
  28. return view('userprofile.index', ['itemsList' => $userItemsList]);
  29. }
  30. public function userProfileInfo()
  31. {
  32. $contentContainer = '';
  33. $contentContainer = RegisterProfileController::createView();
  34. return view('userprofile.index', ["contentContainer" => $contentContainer]);
  35. }
  36. }