當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。