Ejemplo n.º 1
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;
 }