public function invitation($code)
 {
     if (Auth::check()) {
         $string = base64_decode($code);
         $ary = explode('-', $string);
         $email = $ary[0];
         $pId = $ary[1];
         $user = User::where('email', $email)->first();
         if ($user) {
             $user = $user->toArray();
             if (Auth::check()) {
                 if (Auth::user()->email == $user['email']) {
                     ProjectUser::where('project_id', $pId)->where('user_id', $user['id'])->update(['invitation' => 1]);
                     $project = Project::find($pId)->toArray();
                     $message = 'You are now member of project ' . $project['name'];
                     return Response()->json(ResponseManager::getResult($ary, 10, $message));
                 } else {
                     Auth::logout();
                     Session::flush();
                     $message = 'Please login with the email id on which you receive the invitation.';
                     return Response()->json(ResponseManager::getError('', 101, $message));
                 }
             } else {
                 $message = 'Plese login to accept the invitation';
                 return Response()->json(ResponseManager::getError('', 1010, $message));
             }
         } else {
             $message = 'You are not register with us. Please register with us.';
             return Response()->json(ResponseManager::getError('', 2020, $message));
         }
     } else {
         $message = 'Plese login to accept the invitation';
         return Response()->json(ResponseManager::getError('', 10, $message));
     }
 }
Ejemplo n.º 2
0
 public static function getProjectUsers($iProjectId)
 {
     $projectUsers = ProjectUser::where('projectId', $iProjectId)->orderBy('created_at', 'DESC')->get();
     $users = [];
     foreach ($projectUsers as $v) {
         $users[] = User::find($v->userId);
     }
     return $users;
 }
Ejemplo n.º 3
0
 protected function addProjectUser()
 {
     $iProjectId = $this->request->iProjectId;
     $aUsersId = json_decode($this->request->aUsersId);
     foreach ($aUsersId as $userId) {
         $bSuccess = ProjectUser::create(['projectId' => $iProjectId, 'userId' => $userId, 'status' => 'active']);
     }
     if ($bSuccess) {
         $oUsers = ['oProjectUser' => ProjectUser::getProjectUsers($iProjectId), 'message' => 'Users successfully added.'];
         return response()->json($oUsers);
     }
 }
 public function makeProOwner()
 {
     $input = Request::all();
     // project_id,id
     //chk login user is whether project owner or not
     $project = Project::with(['user', 'users'])->find($input['project_id']);
     if ($project) {
         $user = Auth::User()->id;
         $project = $project->toArray();
         $owner = false;
         if ($user == $project['user_id']) {
             $owner = true;
         }
         if (count($project['users']) > 0) {
             foreach ($project['users'] as &$us) {
                 if ($us['is_owner'] && $user == $us['user_id']) {
                     $owner = true;
                 }
             }
         }
         if ($owner) {
             $update = ProjectUser::where('id', $input['id'])->update(['is_owner' => 1]);
             if ($update) {
                 $message = 'Success.';
                 return Response()->json(ResponseManager::getResult($project, 10, $message));
             } else {
                 $message = 'Something went wrong. Please try again.';
                 return Response()->json(ResponseManager::getError('', 10, $message));
             }
         } else {
             $message = 'You are not authorize to do it.';
             return Response()->json(ResponseManager::getError('', 10, $message));
         }
     } else {
         $message = 'You are not authorize to do it.';
         return Response()->json(ResponseManager::getError('', 10, $message));
     }
 }
Ejemplo n.º 5
0
 /**
  * Finds the ProjectUser model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ProjectUser the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ProjectUser::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }