Ejemplo n.º 1
0
 public function creategroup()
 {
     $curdate = date('Y-m-d h:i:s');
     $inputdetails['groupname'] = Input::get('groupname');
     $inputdetails['createdby'] = Input::get('userid');
     $inputdetails['createddate'] = $curdate;
     $inputdetails['grouptype'] = Input::get('grouptype');
     //$inputdetails['groupimage'] = Input::file('uploadimage');
     $inputdetails['status'] = 1;
     $userid = Input::get('userid');
     $validation = Validator::make($inputdetails, groupModel::$rules);
     if ($validation->passes()) {
         if (Input::file('uploadimage') != '') {
             $destinationPath = 'public/assets/upload/group';
             $filename = Input::file('uploadimage')->getClientOriginalName();
             $Image = str_random(8) . '_' . $filename;
             $inputdetails['groupimage'] = $Image;
             $file = Input::file('uploadimage');
             $uploadSuccess = $file->move($destinationPath, $Image);
         }
         $savegroup = groupModel::create($inputdetails);
         $group_id = groupModel::max('id');
         //// Group Owner add in the group member table////
         $inputgroupmember['group_id'] = $group_id;
         $inputgroupmember['user_id'] = $userid;
         $inputgroupmember['createddate'] = $curdate;
         $groupmember = groupmemberModel::create($inputgroupmember);
         ///if Followers or following checked And the group Private //////////
         ////////////
         if ($inputdetails['grouptype'] == 'private') {
             //return Input::get('follower');
             if (Input::get('follower')) {
                 $follower = followModel::select('followerid as id')->where('userid', $userid)->get();
             }
             if (Input::get('following')) {
                 $following = followModel::select('userid as id')->where('followerid', $userid)->get();
             }
             if (Input::get('follower') || Input::get('following')) {
                 if (Input::get('follower')) {
                     for ($i = 0; $i < count($follower); $i++) {
                         $id[$i] = $follower[$i]['id'];
                     }
                 }
                 if (Input::get('following')) {
                     for ($i = 0; $i < count($following); $i++) {
                         $id1[$i] = $following[$i]['id'];
                     }
                 }
                 if (Input::get('follower') != 0 && count($follower) >= 1 && Input::get('following') != 0 && count($following) >= 1) {
                     $id = array_values(array_unique(array_merge($id, $id1)));
                 } elseif (Input::get('following') != 0 && count($following) >= 1) {
                     $id = $id1;
                 } elseif (Input::get('follower') != 0 && count($follower) >= 1) {
                     $id = $id;
                 } else {
                     $data = 'no Data Available in this condition';
                 }
                 //return $id;
                 $inviteinputdetails['inviteddate'] = $curdate;
                 $inviteinputdetails['group_id'] = $group_id;
                 for ($i = 0; $i < count($id); $i++) {
                     $inviteinputdetails['user_id'] = $id[$i];
                     $inviteinputdetails['invitetype'] = 'm';
                     $invite = invitememberforgroupModel::create($inviteinputdetails);
                     if ($invite) {
                         // HERE SET THE NOTIFIATION //
                     }
                 }
             }
         }
         ///////////
         if ($savegroup) {
             $Response = array('success' => '1', 'message' => 'Group Details saved successfully', 'msgcode' => "c141");
             $final = array("response" => $Response);
             return json_encode($final);
         }
     } else {
         $Response = array('success' => '0', 'message' => $validation->messages()->first(), 'msgcode' => "c142");
         $final = array("response" => $Response);
         return json_encode($final);
     }
 }
Ejemplo n.º 2
0
 public function creategroupinweb()
 {
     $userid = Auth::user()->ID;
     $curdate = date('Y-m-d h:i:s');
     $inputdetails['groupname'] = Input::get('groupname');
     $inputdetails['createdby'] = $userid;
     $inputdetails['createddate'] = $curdate;
     $inputdetails['grouptype'] = Input::get('grouptype');
     $inputdetails['status'] = 1;
     if (Input::file('groupimage')) {
         $inputdetails['groupimage'] = Input::file('groupimage');
         $destinationPath = 'public/assets/upload/group';
         $filename = Input::file('groupimage')->getClientOriginalName();
         $Image = str_random(8) . '_' . $filename;
         $inputdetails['groupimage'] = $Image;
     }
     $lantyp = Session::get('language');
     if ($lantyp == "") {
         $lantyp = "value_en";
     }
     $validation = Validator::make($inputdetails, groupModel::$rules);
     if ($validation->passes()) {
         if (Input::file('groupimage')) {
             $file = Input::file('groupimage');
             $uploadSuccess = $file->move($destinationPath, $Image);
         }
         $savegroup = groupModel::create($inputdetails);
         $group_id = groupModel::max('id');
         //// Group Owner add in the group member table////
         $inputgroupmember['group_id'] = $group_id;
         $inputgroupmember['user_id'] = $userid;
         $inputgroupmember['createddate'] = $curdate;
         $groupmember = groupmemberModel::create($inputgroupmember);
         ///if Followers or following checked And the group Private //////////
         ////////////
         if ($inputdetails['grouptype'] == 'private') {
             //return Input::get('follower');
             if (Input::get('follower')) {
                 $follower = followModel::select('followerid as id')->where('userid', $userid)->get();
             }
             if (Input::get('following')) {
                 $following = followModel::select('userid as id')->where('followerid', $userid)->get();
             }
             if (Input::get('follower') || Input::get('following')) {
                 if (Input::get('follower')) {
                     for ($i = 0; $i < count($follower); $i++) {
                         $id[$i] = $follower[$i]['id'];
                     }
                 }
                 if (Input::get('following')) {
                     for ($j = 0; $j < count($following); $j++) {
                         $id1[$j] = $following[$j]['id'];
                     }
                 }
                 if (Input::get('follower') != 0 && count($follower) >= 1 && Input::get('following') != 0 && count($following) >= 1) {
                     $id = array_values(array_unique(array_merge($id, $id1)));
                 } elseif (Input::get('following') != 0 && count($following) >= 1) {
                     $id = $id1;
                 } elseif (Input::get('follower') != 0 && count($follower) >= 1) {
                     $id = $id;
                 } else {
                     $id = 0;
                 }
                 $inviteinputdetails['inviteddate'] = $curdate;
                 $inviteinputdetails['group_id'] = $group_id;
                 if ($id != 0) {
                     for ($i = 0; $i < count($id); $i++) {
                         $inviteinputdetails['user_id'] = $id[$i];
                         $inviteinputdetails['invitetype'] = 'm';
                         $invite = invitememberforgroupModel::create($inviteinputdetails);
                         if ($invite) {
                             // HERE SET THE NOTIFIATION //
                         }
                     }
                 }
             }
         }
         ///////////
         if ($savegroup) {
             $languageDetails = languageModel::select($lantyp, 'ctrlCaptionId')->whereIn('value_en', ['Group Details Added successfully'])->get()->toArray();
             foreach ($languageDetails as $key => $val) {
                 $er_data['messagesave'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
             }
             return Redirect::to("group")->withInput()->with('er_data', $er_data)->with('tab', 'creategroup');
         }
     } else {
         $languageDetails = languageModel::select($lantyp, 'ctrlCaptionId')->whereIn('value_en', [$validation->messages()->first('groupname')])->get()->toArray();
         foreach ($languageDetails as $key => $val) {
             $er_data['groupname'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
         }
         return Redirect::to("group")->with('er_data', $er_data)->with('tab', 'creategroup');
     }
 }