コード例 #1
0
 /**
  * Delete a specified organization from storage.
  * @param type int $id
  * @return type Redirect
  */
 public function destroy($id, Organization $org, User_org $user_org)
 {
     /* select the field by id  */
     $orgs = $org->whereId($id)->first();
     $user_orgs = $user_org->where('org_id', '=', $id)->get();
     foreach ($user_orgs as $user_org) {
         $user_org->delete();
     }
     /* Delete the field selected from the table */
     /* Check whether function success or not */
     try {
         $orgs->delete();
         /* redirect to Index page with Success Message */
         return redirect('organizations')->with('success', 'Organization  Deleted Successfully');
     } catch (Exception $e) {
         /* redirect to Index page with Fails Message */
         return redirect('organizations')->with('fails', $e->errorInfo[2]);
     }
 }
コード例 #2
0
 /**
  * user create organisation
  * @return type value
  */
 public function User_Create_Org($id)
 {
     if (Input::get('website') != null) {
         // checking website
         $check = Organization::where('website', '=', Input::get('website'))->first();
     } else {
         $check = null;
     }
     // checking name
     $check2 = Organization::where('name', '=', Input::get('name'))->first();
     if (\Input::get('name') == null) {
         return "Name is required";
     } elseif ($check2 != null) {
         return "Name should be Unique";
     } elseif ($check != null) {
         return "Website should be Unique";
     } else {
         $org = new Organization();
         $org->name = Input::get('name');
         $org->phone = Input::get('phone');
         $org->website = Input::get('website');
         $org->address = Input::get('address');
         $org->internal_notes = Input::get('internal');
         $org->save();
         $user_org = new User_org();
         $user_org->org_id = $org->id;
         $user_org->user_id = $id;
         $user_org->save();
         return 0;
     }
 }
コード例 #3
0
 /**
  * creating an organization in user profile page via modal popup
  * @param type $id 
  * @return type
  */
 public function User_Create_Org($id)
 {
     // checking if the entered value for website is available in database
     if (Input::get('website') != null) {
         // checking website
         $check = Organization::where('website', '=', Input::get('website'))->first();
     } else {
         $check = null;
     }
     // checking if the name is unique
     $check2 = Organization::where('name', '=', Input::get('name'))->first();
     // if any of the fields is not available then return false
     if (\Input::get('name') == null) {
         return "Name is required";
     } elseif ($check2 != null) {
         return "Name should be Unique";
     } elseif ($check != null) {
         return "Website should be Unique";
     } else {
         // storing organization details and assigning the current user to that organization
         $org = new Organization();
         $org->name = Input::get('name');
         $org->phone = Input::get('phone');
         $org->website = Input::get('website');
         $org->address = Input::get('address');
         $org->internal_notes = Input::get('internal');
         $org->save();
         $user_org = new User_org();
         $user_org->org_id = $org->id;
         $user_org->user_id = $id;
         $user_org->save();
         // for success return 0
         return 0;
     }
 }