Esempio n. 1
0
 /**
  * Reject Studio Request
  *
  * @param  int  $id
  * @return Response
  */
 public function rejectStudio(Request $request)
 {
     $res = array();
     $res['success'] = false;
     $artistStudioRequest = ArtistStudioRequest::find($request->input('id'));
     $user = Auth::user();
     $artist = Artist::where('user_id', $user->id)->first();
     if ($artistStudioRequest->artist_id == $artist->id) {
         $artistStudioRequest->declined = true;
         $artistStudioRequest->save();
         $res['message'] = 'Request is declined!';
         $res['success'] = false;
         session()->flash('success', 'Request Declined!');
     }
     return $res;
 }
Esempio n. 2
0
 /**
  * send a request to artist
  *
  * @return View
  */
 public function sendArtistRequest(Request $request)
 {
     $res = array();
     $res['success'] = false;
     $artistId = $request->input('id');
     $user = Auth::user();
     $studio = Studio::where('user_id', $user->id)->first();
     if (ArtistStudioRequest::where('studio_id', $studio->id)->where('artist_id', $artistId)->count()) {
         $res['message'] = 'Waiting for artist\'s approval!';
         return $res;
     }
     if ($studio->artists->where('artist_id', $artistId)->count()) {
         $res['message'] = 'Studio has already been added to your profile!';
         return $res;
     } else {
         $studioRequest = new ArtistStudioRequest();
         $studioRequest->artist_id = $artistId;
         $studioRequest->studio_id = $studio->id;
         $studioRequest->requestedByArtist = false;
         $studioRequest->declined = false;
         if ($studioRequest->save()) {
             $res['success'] = true;
             $res['message'] = 'Your request has been sent to artist for approval!!';
         }
     }
     return $res;
 }
Esempio n. 3
0
 /**
  * Display User Profile Page
  *
  * @return View
  */
 public function profile()
 {
     $user = Auth::user();
     // session()->reflash();
     $showWelcomeMessage = false;
     if (!$user->welcomed) {
         $showWelcomeMessage = true;
         $user->welcomed = true;
         $user->save();
     }
     //if user is artist, load artist profile view
     if ($user->type == 'artist') {
         $artist = Artist::where('user_id', $user->id)->first();
         $pendingRequests = ArtistStudioRequest::where('artist_id', $artist->id)->where('requestedByArtist', false)->where('declined', false)->get();
         $isArtistProfile = true;
         if (Auth::check()) {
             $user = Auth::user();
             if ($artist->user_id == Auth::User()->id) {
                 $isArtistProfile = true;
                 $artistTattoos = $artist->user->tattoos()->where('approved', 1)->paginate(7);
             } else {
                 $artistTattoos = $artist->user->tattoos()->where('approved', 1)->paginate(7);
             }
             if (Follower::where('user_id', $artist->user->id)->where('follower_id', $user->id)->count()) {
                 $isFollowing = true;
             }
         } else {
             $artistTattoos = $artist->user->tattoos()->where('approved', 1)->paginate(7);
         }
         $pendingRequests = ArtistStudioRequest::where('artist_id', $artist->id)->where('declined', false)->get();
         $artist->cover = url('uploads/images/large/' . $artist->cover);
         $fanTattoos = $artist->tattoos()->where('user_id', '<>', $artist->user_id)->where('approved', 1)->get();
         return view('pages.artist', ['fanTattoos' => $fanTattoos, 'artistTattoos' => $artistTattoos, 'isArtistProfile' => $isArtistProfile, 'isSelf' => $isArtistProfile, 'artist' => $artist, 'pendingRequests' => $pendingRequests, 'showWelcomeMessage' => $showWelcomeMessage]);
     } elseif ($user->type == 'studio') {
         $studio = Studio::where('user_id', $user->id)->first();
         $studio->cover = url('uploads/images/large/' . $studio->cover);
         $pendingRequests = ArtistStudioRequest::where('studio_id', $studio->id)->where('requestedByArtist', true)->where('declined', false)->get();
         $isArtistProfile = true;
         return view('pages.studio', ['user' => $user, 'studio' => $studio, 'isArtistProfile' => $isArtistProfile, 'pendingRequests' => $pendingRequests, 'showWelcomeMessage' => $showWelcomeMessage]);
     } elseif ($user->type == 'member') {
         $member = Member::where('user_id', $user->id)->first();
         $artists = Artist::where('verified', true)->orderBy('firstname', 'asc')->get();
         $categories = Tag::where('isCategory', true)->get();
         $isMemberProfile = true;
         $isFollowing = false;
         if (Auth::check()) {
             if ($member->user_id == Auth::User()->id) {
                 $isMemberProfile = true;
             }
             if (Follower::where('user_id', $member->user->id)->where('follower_id', $user->id)->count()) {
                 $isFollowing = true;
             }
         }
         return view('pages.member', ['member' => $member, 'isMemberProfile' => $isMemberProfile, 'isFollowing' => $isFollowing, 'artists' => $artists, 'categories' => $categories, 'showWelcomeMessage' => $showWelcomeMessage]);
     } else {
         return redirect('complete-profile')->flash('success', 'Welcome. Please complete your profile..');
     }
     return redirect('/');
 }