Example #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('events')->insert([['id' => '1', 'eventName' => 'PartyNight', 'date' => '2016-01-01', 'startTime' => '14:00:00', 'endTime' => '15:00:00', 'location' => 'Beijing', 'description' => 'A test Event 1.', 'capacity' => 123, 'conferenceID' => 1], ['id' => '2', 'eventName' => 'Speech', 'date' => '2017-01-01', 'startTime' => '12:00:00', 'endTime' => '12:30:00', 'location' => 'Mumbai', 'description' => 'A test Event 2.', 'capacity' => 123, 'conferenceID' => 1]]);
     $role = RoleCreate::AllEventRoles(1);
     Account::where('email', 'root@localhost')->get()->first()->attachRole($role);
     $role = RoleCreate::AllEventRoles(2);
     Account::where('email', 'root@localhost')->get()->first()->attachRole($role);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $conferences = [['id' => 1, 'conferenceName' => 'Foo', 'dateStart' => '2016-01-01', 'dateEnd' => '2016-02-01', 'location' => 'Earth', 'description' => 'A test conference.', 'hasTransportation' => true, 'hasAccommodations' => false], ['id' => 2, 'conferenceName' => 'Bar', 'dateStart' => '2016-02-03', 'dateEnd' => '2016-02-05', 'location' => 'Earth', 'description' => 'A test conference number 2.', 'hasTransportation' => true, 'hasAccommodations' => true]];
     foreach ($conferences as $conf) {
         $c = Conference::create($conf);
         $role = RoleCreate::AllConferenceRoles($c->id);
         Account::where('email', 'root@localhost')->get()->first()->attachRole($role);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('roles')->delete();
     /**
      * Role Attributes
      *
      * name:    Unique name for the permission, used for looking up permission information in the
      *             application layer. For example: "create-post", "edit-user", "post-payment", "mailing-list-subscribe".
      *
      * display_name:    Human readable name for the permission. Not necessarily unique, and is optional.
      *                     For example "Create Posts", "Edit Users", "Post Payments", "Subscribe to mailing list".
      *
      * description:     A more detailed explanation of the Role. This is also optional.
      *
      * permissions: A list of permission names to assign to the user.  Optional.
      */
     $roles = array(array('name' => 'owner', 'display_name' => 'Owner', 'description' => 'Owner of the management system. Has access to all aspects of the system.', 'permissions' => PermissionNames::AllGlobalPermissions()));
     foreach ($roles as $r) {
         $entry = new Role();
         $entry->name = $r['name'];
         if (array_key_exists('permissions', $r)) {
             $permissions = $r['permissions'];
             unset($r['permissions']);
         }
         if (array_key_exists('display_name', $r)) {
             $entry->display_name = $r['display_name'];
         }
         if (array_key_exists('description', $r)) {
             $entry->description = $r['description'];
         }
         $entry->save();
         if (isset($permissions)) {
             foreach ($permissions as $p) {
                 $entry->attachPermission(Permission::where('name', $p)->get()->first());
             }
             unset($permissions);
         }
     }
     $rolePermissions = Permission::whereIn('name', PermissionNames::AllGlobalPermissions())->get();
     RoleCreate::createPermissionRoles($rolePermissions);
 }
Example #4
0
 /**
  * Remove the event given the eventID.
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (!Entrust::hasRole(RoleNames::EventManager($id))) {
         return response("Permission not found", 403);
     }
     return DB::transaction(function () use($id) {
         $event = Event::find($id);
         if (is_null($event)) {
             return response("No event for id {$id}.", 404);
         }
         $event->delete();
         Permission::whereIn('name', PermissionNames::AllEventPermissions($id))->delete();
         RoleCreate::deleteEventRoles($id);
         return response()->json(['id' => $event->id]);
     });
 }
Example #5
0
 /**
  * Deletes a conference.
  */
 public function delete($id)
 {
     if (!Entrust::can(PermissionNames::ConferenceInfoEdit($id))) {
         return response("", 403);
     }
     DB::transaction(function () use($id) {
         $events = Event::where('conferenceID', $id)->get();
         $pnames = array_merge(PermissionNames::AllConferencePermissions($id), PermissionNames::ExclusiveConferencePermissions($id));
         $evtIds = [];
         foreach ($events as $e) {
             $pnames = array_merge($pnames, PermissionNames::AllEventPermissions($e->id));
             echo $e;
             $evtIds[] = $e->id;
         }
         Permission::whereIn('name', $pnames)->delete();
         RoleCreate::deleteConferenceRoles($id);
         RoleCreate::deleteEventRoles($evtIds);
         Conference::destroy($id);
     });
     Log::info("Conference with ID {$id} deleted");
     return '';
 }