Exemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $permissions = array(array("id" => 1, "name" => "Media Items", "description" => "Allows managing media items."), array("id" => 2, "name" => "Shows", "description" => "Allows managing shows."), array("id" => 3, "name" => "Playlists", "description" => "Allows managing playlists."), array("id" => 4, "name" => "Live Streams", "description" => "Allows configuration of live streams."), array("id" => 5, "name" => "Site Users", "description" => "Allows managing of registered site users."), array("id" => 6, "name" => "CMS Users", "description" => "Allows managing CMS users."), array("id" => 7, "name" => "Site Comments", "description" => "Allows managing site comments and commenting as station."), array("id" => 8, "name" => "API Users", "description" => "Allows managing API users."));
     foreach ($permissions as $a) {
         $p = Permission::find($a['id']);
         if ($p !== NULL) {
             unset($a['id']);
             $p->update($a);
         } else {
             Permission::create($a);
         }
     }
     $this->command->info('Permissions created/updated!');
 }
Exemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     LiveStream::truncate();
     MediaItem::truncate();
     MediaItemComment::truncate();
     MediaItemLike::truncate();
     MediaItemLiveStream::truncate();
     MediaItemVideo::truncate();
     Permission::truncate();
     PermissionGroup::truncate();
     QualityDefinition::truncate();
     LiveStreamUri::truncate();
     Playlist::truncate();
     Show::truncate();
     SiteUser::truncate();
     User::truncate();
     VideoFile::truncate();
     DB::table("media_item_to_playlist")->truncate();
     DB::table("permission_to_group")->truncate();
     DB::table("user_to_group")->truncate();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     $this->command->info('Tables truncated!');
 }
Exemplo n.º 3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $groups = array(array("name" => "Read Only", "description" => "Ability to view most of the settings in the cms.", "permissionIdsFlags" => array(array(1, 0), array(2, 0), array(3, 0), array(4, 0), array(5, 0), array(6, 0), array(8, 0))), array("name" => "Content Management", "description" => "Allows managing media items.", "permissionIdsFlags" => array(array(1, 1))), array("name" => "Shows Management", "description" => "Allows managing shows.", "permissionIdsFlags" => array(array(2, 1))), array("name" => "Playlist Management", "description" => "Allows managing playlists.", "permissionIdsFlags" => array(array(3, 1), array(2, 0), array(1, 0))), array("name" => "Stream Management", "description" => "Allows managing live streams.", "permissionIdsFlags" => array(array(4, 1))), array("name" => "Site Users Management", "description" => "Allows managing site users.", "permissionIdsFlags" => array(array(5, 1))), array("name" => "CMS Users Management", "description" => "Allows managing the CMS users.", "permissionIdsFlags" => array(array(6, 1))), array("name" => "Comments Management", "description" => "Allows managing site comments and commenting as station.", "permissionIdsFlags" => array(array(7, 0))), array("name" => "API Users Management", "description" => "Allows managing API users.", "permissionIdsFlags" => array(array(8, 1))));
     foreach ($groups as $i => $a) {
         $permissionIdsFlags = $a['permissionIdsFlags'];
         unset($a['permissionIdsFlags']);
         $a['position'] = $i;
         $permissionIds = array();
         foreach ($permissionIdsFlags as $b) {
             $permissionIds[] = $b[0];
         }
         $permissions = Permission::whereIn("id", $permissionIds)->get();
         $group = new PermissionGroup($a);
         DB::transaction(function () use(&$group, &$permissions, &$permissionIdsFlags) {
             $group->save();
             foreach ($permissionIdsFlags as $b) {
                 $flag = $b[1];
                 $permissionId = $b[0];
                 $group->permissions()->attach($permissions->find($permissionId), array("permission_flag" => $flag));
             }
         });
     }
     $this->command->info('Permissions groups created and permissions assigned to groups!');
 }