当前位置: 首页>>代码示例>>PHP>>正文


PHP Group::create方法代码示例

本文整理汇总了PHP中Group::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::create方法的具体用法?PHP Group::create怎么用?PHP Group::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Group的用法示例。


在下文中一共展示了Group::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     $groups = [["id" => 1, "name" => "ADMIN"], ["id" => 2, "name" => "USUARIO"]];
     foreach ($groups as $group) {
         Group::create($group);
     }
 }
开发者ID:alejandromorg,项目名称:Inventario,代码行数:7,代码来源:GroupSeeder.php

示例2: requireDefaultRecords

 /**
  * @throws ValidationException
  * @throws null
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     /**
      * Add default site admin group if none with
      * permission code SITE_ADMIN exists
      *
      * @var Group $siteAdminGroup
      */
     $siteAdminGroups = DataObject::get('Group')->filter(array('Code' => 'site-administrators'));
     if (!$siteAdminGroups->count()) {
         $siteAdminGroup = Group::create();
         $siteAdminGroup->Code = 'site-administrators';
         $siteAdminGroup->Title = _t('BoilerplateGroupExtension.SiteAdminGroupTitle', 'Site Administrators');
         $siteAdminGroup->Sort = 0;
         $siteAdminGroup->write();
         /** Default CMS permissions */
         Permission::grant($siteAdminGroup->ID, 'CMS_ACCESS_LeftAndMain');
         Permission::grant($siteAdminGroup->ID, 'SITETREE_VIEW_ALL');
         Permission::grant($siteAdminGroup->ID, 'SITETREE_EDIT_ALL');
         Permission::grant($siteAdminGroup->ID, 'SITETREE_REORGANISE');
         Permission::grant($siteAdminGroup->ID, 'VIEW_DRAFT_CONTENT');
         Permission::grant($siteAdminGroup->ID, 'SITETREE_GRANT_ACCESS');
         Permission::grant($siteAdminGroup->ID, 'EDIT_SITECONFIG');
     }
 }
开发者ID:helpfulrobot,项目名称:ryanpotter-silverstripe-boilerplate,代码行数:30,代码来源:BoilerplateGroupExtension.php

示例3: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Group::create(['name' => $faker->randomDigit]);
     }
 }
开发者ID:sharad23,项目名称:power,代码行数:7,代码来源:GroupsTableSeeder.php

示例4: Register

 public function Register($data, Form $form)
 {
     if (!Member::currentUser()) {
         $member = new Member();
         // Debug::show($form);
         $form->saveInto($member);
         if (Group::get()->filter('Title', 'Subscribed')->count() == 0) {
             $group = Group::create();
             $group->Title = 'Subscribed';
             $group->write();
         } else {
             $group = Group::get()->filter('Title', 'Subscribed')->First();
         }
         if (Member::get()->filter('Email', $data['Email'])) {
             $form->addErrorMessage('Email', 'That email address is already in use. <a href="Security/login">login</a>', 'bad', true, true);
             //Controller::curr()->redirect('register');
         } else {
             //has to be called before setting group
             $member->write();
             if (!$member->inGroup($group)) {
                 $member->Groups()->add($group);
             }
         }
     }
     Controller::curr()->redirectBack();
 }
开发者ID:vinstah,项目名称:body,代码行数:26,代码来源:RegisterMemberPage.php

示例5: create

 function create($page = NULL)
 {
     //load block submit helper and append in the head
     $this->template->append_metadata(block_submit_button());
     //create control variables
     $this->template->title(lang('web_add_group'));
     $this->template->set('updType', 'create');
     $this->template->set('page', $this->uri->segment(4) ? $this->uri->segment(4) : $this->input->post('page', TRUE));
     //Rules for validation
     $this->set_rules();
     //validate the fields of form
     if ($this->form_validation->run() == FALSE) {
         //load the view
         $this->template->build('groups/create');
     } else {
         //Validation OK!
         $form_data = array('name' => set_value('name'), 'description' => set_value('description'));
         $group = Group::create($form_data);
         if ($group->is_valid()) {
             $this->session->set_flashdata('message', array('type' => 'success', 'text' => lang('web_create_success')));
         }
         if ($group->is_invalid()) {
             $this->session->set_flashdata('message', array('type' => 'error', 'text' => $group->errors->full_messages()));
         }
         redirect('/admin/groups/');
     }
 }
开发者ID:csiber,项目名称:CodeIgniter-Starter,代码行数:27,代码来源:groups.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('groups')->delete();
     Group::create(array('name' => 'Megacities'));
     Group::create(array('name' => 'House, mouse ...'));
     Group::create(array('name' => 'Last year'));
 }
开发者ID:PhilippHofer,项目名称:ev,代码行数:12,代码来源:GroupTableSeeder.php

示例7: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Group::create([]);
     }
 }
开发者ID:dynamicsystems,项目名称:TechTracker,代码行数:7,代码来源:GroupsTableSeeder.php

示例8: post_index

 public function post_index()
 {
     $group = array('name' => Input::get('name'), 'description' => Input::get('description'));
     $new_group = Group::create($group);
     if ($new_group) {
         return Redirect::to_action('groups');
     }
 }
开发者ID:gigikiri,项目名称:masjid-l3,代码行数:8,代码来源:groups.php

示例9: setUp

 protected function setUp()
 {
     $grp = new Group();
     $grp->destroy();
     for ($i = 0; $i < 10; $i++) {
         $grp->create(array("title" => "title" . $i, "memo" => "memomemo"));
         $grp->save();
     }
 }
开发者ID:hirakiuc,项目名称:ChainRecord,代码行数:9,代码来源:chain_record_chain_test.php

示例10: store

 /**
  * Store a newly created group in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Group::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     Group::create($data);
     return Redirect::route('groups.index');
 }
开发者ID:sharad23,项目名称:power,代码行数:14,代码来源:GroupsController.php

示例11: testAdminUser

 public function testAdminUser()
 {
     $user = User::create(array('username' => 'testuser'));
     $user->save();
     $group = Group::create(array('name' => 'An admin group', 'is_admin' => true));
     $user->groups()->attach($group->id);
     $article = new Article();
     $article->body = 'can you access this?';
     $article->save();
     $this->assertTrue($this->redoubt->userCan('edit', $article, $user));
 }
开发者ID:georgebohnisch,项目名称:redoubt-plus,代码行数:11,代码来源:UserTest.php

示例12: build

 /**
  * @param string$code
  * @param null|string $title
  * @param null|string $description
  * @return ISecurityGroup
  */
 public function build($code, $title = null, $description = null)
 {
     $group = Group::create();
     $group->Code = $code;
     if (is_null($title)) {
         $title = ucfirst($code);
     }
     $group->Title = $title;
     if (!is_null($description)) {
         $group->Description = $description;
     }
     return $group;
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:19,代码来源:SecurityGroupFactory.php

示例13: doUp

 function doUp()
 {
     global $database;
     if (intval(Group::get()->filter('Code', 'SUMMIT_FRONT_END_ADMINISTRATORS')->count()) > 0) {
         return;
     }
     $g = Group::create();
     $g->setTitle('Summit Front End Administrators');
     $g->setDescription('Allows to Access to summit-admin application');
     $g->setSlug('SUMMIT_FRONT_END_ADMINISTRATORS');
     $g->write();
     Permission::grant($g->getIdentifier(), 'ADMIN_SUMMIT_APP_FRONTEND_ADMIN');
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:13,代码来源:CreateSummitFrontEndAdminGroupMigration.php

示例14: run

 public function run()
 {
     if (Group::count('id')) {
         echo 'Skipping group seeder' . "\n";
         return;
     }
     $groups = [['title' => 'Ожидающий доступа', 'configs' => ['stars' => 0, 'title' => 'Ожидающий доступа', 'conf_show_signature' => false]], ['title' => 'Администратор', 'configs' => ['title' => 'Администратор']], ['title' => 'Newbie', 'configs' => ['stars' => 0, 'title' => 'Ньюбл', 'conf_show_signature' => false]], ['title' => 'Junior', 'configs' => ['stars' => 1, 'title' => 'Юниор']], ['title' => 'Member', 'configs' => ['stars' => 2, 'title' => 'Участник']], ['title' => 'Full Member', 'configs' => ['stars' => 3, 'title' => 'Уверенный пользователь']], ['title' => 'Senior Member', 'configs' => ['stars' => 4, 'title' => 'Сеньор']], ['title' => 'Profi', 'configs' => ['stars' => 5, 'title' => 'Профи']], ['title' => 'Master', 'configs' => ['stars' => 6, 'title' => 'Мастер']], ['title' => 'Guru', 'configs' => ['stars' => 7, 'title' => 'Гуру']], ['title' => 'Monster', 'configs' => ['stars' => 8, 'title' => 'Монстр']], ['title' => 'Wizard', 'configs' => ['stars' => 9, 'title' => 'Волшебник']], ['title' => 'God', 'configs' => ['stars' => 10, 'title' => 'Бог']], ['title' => 'Нарушившие правила', 'configs' => ['title' => 'Нарушитель', 'conf_show_signature' => false]], ['title' => 'Бан', 'configs' => ['title' => 'В бане', 'conf_show_signature' => false]], ['title' => 'Комодератор', 'configs' => ['title' => 'Помошник модератора']], ['title' => 'Модератор', 'configs' => ['title' => 'Модератор']], ['title' => 'Супермодератор', 'configs' => ['title' => 'Супермод']], ['title' => 'Ветеран', 'configs' => ['title' => 'Ветеран']], ['title' => 'Участники клуба Sources.RU', 'configs' => ['title' => 'Клубень']]];
     DB::transaction(function () use($groups) {
         foreach ($groups as $group) {
             Group::create($group);
         }
     });
 }
开发者ID:Developers-RuDev,项目名称:forum.next,代码行数:13,代码来源:GroupsTableSeeder.php

示例15: storeAction

 /**
  * Create a new group
  */
 public function storeAction()
 {
     $validation = Validator::make(Input::all(), Group::$rules);
     if (!$validation->passes()) {
         return Redirect::route('groups.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
     }
     /**
      * Check name duplicates
      */
     if (count(Group::where('name', Input::get('name'))->get())) {
         return Redirect::route('groups.create')->withInput()->with('message', 'This group already exists.');
     }
     $group = Group::create(Input::all());
     return Redirect::route('groups.show', $group->id);
 }
开发者ID:himor,项目名称:testing,代码行数:18,代码来源:GroupController.php


注:本文中的Group::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。