示例#1
0
 /**
  * Store a new group from form request
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store(Request $request)
 {
     $this->authorize('edit_users');
     $this->validate($request, ['name' => 'required|string|between:3,50', 'description' => 'string|between:0,100', 'permission_list' => 'array']);
     $group = Group::create($request->all());
     $group->permissions()->attach($request->input('permission_list'));
     flash()->success('Group Saved', 'The group has been created');
     return redirect('group');
 }
示例#2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store($society, GroupsRequest $request)
 {
     $group = Group::create($request->except('centrelat', 'centrelong', 'files'));
     $group->publish = $request->input('publish', false);
     $group->save();
     $indiv = Individual::find($request->input('contact'));
     $group->individual()->save($indiv);
     $update = Group::find($group->id)->individual()->updateExistingPivot($request->input('contact'), array('created_at' => DB::raw('NOW()')));
     return Redirect::route('society.groups.index', $society)->with('okmessage', 'New group has been added');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(GroupRequest $request)
 {
     $input = $request->all();
     $newpermission = false;
     $permissions = $request->get('permissions');
     $newpermission = static::format_per($permissions);
     $input['permissions'] = !empty($newpermission) ? json_encode($newpermission) : '';
     Group::create($input);
     Session::flash('success', Lang::get('ruban.group.created'));
     return Redirect::route('ruban.groups.index');
 }
示例#4
0
 public function run()
 {
     DB::statement('TRUNCATE TABLE t_px_group CASCADE');
     $group = Group::create(array('name' => '超级管理员'));
     $group->permissions()->sync(['setting.edit', 'user.add', 'user.edit', 'user.show', 'user.list', 'user.save', 'user.update', 'user.delete', 'user.reset', 'user.change', 'user.saveChange', 'user.profile', 'group.add', 'group.edit', 'group.show', 'group.list', 'group.save', 'group.update', 'group.delete', 'group.grant', 'group.saveGrant', 'permission.add', 'permission.edit', 'permission.show', 'permission.list', 'permission.save', 'permission.update', 'permission.delete', 'pjzb.add', 'pjzb.edit', 'pjzb.show', 'pjzb.list', 'pjzb.save', 'pjzb.update', 'pjzb.delete', 'pjbz.add', 'pjbz.edit', 'pjbz.show', 'pjbz.list', 'pjbz.save', 'pjbz.update', 'pjbz.delete', 'pfdj.add', 'pfdj.edit', 'pfdj.show', 'pfdj.list', 'pfdj.save', 'pfdj.update', 'pfdj.delete', 'pfjg.monitor', 'pfjg.departmentMonitor', 'pfjg.statistics', 'pfjg.departmentStatistics', 'pfjg.majorStatistics', 'pfjg.exportMonitor', 'pfjg.exportDepartmentMonitor', 'pfjg.exportStatistics', 'pfjg.exportDepartmentStatistics', 'pfjg.exportMajorStatistics']);
     $group = Group::create(array('name' => '年级辅导员'));
     $group->permissions()->sync(['user.change', 'user.saveChange', 'user.profile', 'pfjg.majorStatistics', 'pfjg.exportMajorStatistics']);
     $group = Group::create(array('name' => '教学秘书'));
     $group->permissions()->sync(['user.change', 'user.saveChange', 'user.profile', 'pfjg.departmentMonitor', 'pfjg.exportDepartmentMonitor', 'pfjg.departmentStatistics', 'pfjg.exportDepartmentStatistics']);
     $group = Group::create(array('name' => '学校领导'));
     $group->permissions()->sync(['user.change', 'user.saveChange', 'user.profile', 'pfjg.statistics', 'pfjg.exportStatistics']);
 }
示例#5
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create(Request $request)
 {
     //
     if ($request->isMethod('get')) {
         return view('admin.group.create');
     }
     $groupname = $request->input('groupname', null);
     if (empty($groupname)) {
         session()->flash('msg_error', '请输入组名');
         return back();
     }
     $oGroup = Group::create(['name' => $groupname]);
     Admin::join_group($oGroup->id, session('admin_id'));
     session()->flash('msg_success', '创建成功,请分配权限');
     return redirect(route('admin::group.edit', [$oGroup->id]));
 }
 public function run()
 {
     $date = new \DateTime();
     $people = $users = $userGroups = $groupList = $teamMembers = $members = $userAccounts = $teams = $teamLanguages = $teamLanguageSupports = [];
     //Reading the CSV file to get a list of groups
     $groupCSV = \League\Csv\Reader::createFromPath($this->baseDir . 'users_groups_permissions.tsv', 'r');
     $groupCSV->setDelimiter(chr(9));
     $groupCSVData = $groupCSV->fetchAssoc();
     foreach ($groupCSVData as $data) {
         if ($data['group_name'] != 'users' && $data['group_name'] != 'administrators') {
             Models\Group::create(['group_name' => $data['group_name']]);
         }
     }
     //Getting the groups we just created from the db and an associative array
     $dbGroups = Models\Group::query()->pluck('group_id', 'group_name')->toArray();
     //Every user gets a password of test, for testing purposes
     $userPassword = bcrypt('test');
     $personDBColumns = $this->getFillableDBModelFields('\\App\\Models\\Person');
     //Reading the users CSV file
     $userCSV = \League\Csv\Reader::createFromPath($this->baseDir . 'users.tsv', 'r');
     $userCSV->setDelimiter(chr(9));
     $userCSVData = $userCSV->fetchAssoc();
     foreach ($userCSVData as $key => $data) {
         //We use every column in the CSV whose name matches with a field in the people table
         $people[$key] = $this->fillArrayFromModel($data, array_flip($personDBColumns));
         $people[$key]['person_birthdate'] = strtotime($people[$key]['person_birthdate']);
         $users[$key] = ['email' => $data['email'], 'name' => $data['name'], 'password' => $userPassword, 'activated' => true, 'last_login' => $date, 'created_at' => $date];
         $users[$key]['person_id'] = $key + 1;
         //Adding users to their groups
         if (!empty($data['groups'])) {
             $groups = explode(',', $data['groups']);
             if (!empty($groups)) {
                 foreach ($groups as $group) {
                     if (isset($dbGroups[$group]) && $group != 'users') {
                         $userGroups[] = ['user_id' => $key + 1, 'group_id' => $dbGroups[$group]];
                     }
                 }
             }
         }
         //Everyone gets to be a part of the users group, yay!
         $userGroups[] = ['user_id' => $key + 1, 'group_id' => Models\Group::users];
     }
     DB::table('people')->insert($people);
     DB::table('users')->insert($users);
     DB::table('user_groups')->insert($userGroups);
     $this->command->info('Users & Groups seeded');
 }
示例#7
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     $Role1 = \App\Models\Role::create(['title' => 'Пользователь', 'default' => true]);
     $Role2 = \App\Models\Role::create(['title' => 'Администратор', 'admin' => true]);
     \App\Models\Group::create(['title' => 'КИТ-10']);
     $Group1 = \App\Models\Group::create(['title' => 'КИТ-10']);
     \App\Models\Group::create(['title' => 'КИТ-20']);
     $Group2 = \App\Models\Group::create(['title' => 'КИТ-30']);
     \App\Models\Group::create(['title' => 'КИТ-40']);
     \App\User::create(['first_name' => 'Admin', 'last_name' => 'Admin', 'second_name' => 'Admin', 'email' => '*****@*****.**', 'password' => bcrypt('admin'), 'group_id' => $Group2->id, 'role_id' => $Role2->id]);
     \App\User::create(['first_name' => 'Test first name', 'last_name' => 'Test last name', 'second_name' => 'Test second name', 'email' => '*****@*****.**', 'password' => bcrypt('123456'), 'group_id' => $Group1->id, 'role_id' => $Role1->id]);
     \Illuminate\Support\Facades\DB::table('type_question')->insert([['title' => 'radio'], ['title' => 'checkbox']]);
     $Prototype = \App\Models\Prototype::create(['title' => 'Тест по биологии', 'time' => 40, 'count_questions' => 5]);
     $Question = \App\Models\Question::create(['prototype_id' => $Prototype->id, 'text' => 'Сколько лап у ежа?', 'type' => 'radio']);
     $Answer = \App\Models\Answer::create(['text' => '4', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '6', 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'Много', 'question_id' => $Question->id]);
     $Question = \App\Models\Question::create(['prototype_id' => $Prototype->id, 'text' => 'Какая длина хобота у слона?', 'type' => 'radio']);
     $Answer = \App\Models\Answer::create(['text' => 'У слона нет хобота', 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '2 метра', 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'Зависит от возраста', 'right' => true, 'question_id' => $Question->id]);
     $Question = \App\Models\Question::create(['prototype_id' => $Prototype->id, 'text' => 'Сколько рёбер у человека?', 'type' => 'radio']);
     $Answer = \App\Models\Answer::create(['text' => '12 пар', 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'Кто такой человек?', 'right' => true, 'question_id' => $Question->id]);
     $Question = \App\Models\Question::create(['prototype_id' => $Prototype->id, 'text' => 'Какие типы данных из перечисленных есть в PHP?', 'type' => 'checkbox']);
     $Answer = \App\Models\Answer::create(['text' => 'Integer', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'Float', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'String', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'Char', 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'Array', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'Callbacks / Callables', 'right' => true, 'question_id' => $Question->id]);
     $Question = \App\Models\Question::create(['prototype_id' => $Prototype->id, 'text' => 'Какой оператор выполняет строгое сравнение?', 'type' => 'radio']);
     $Answer = \App\Models\Answer::create(['text' => '==', 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '===', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '&', 'question_id' => $Question->id]);
     $Question = \App\Models\Question::create(['prototype_id' => $Prototype->id, 'text' => 'Какой оператор не правильный?', 'type' => 'radio']);
     $Answer = \App\Models\Answer::create(['text' => '$a and $b', 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '$a or $b', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '! $a', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '$a => $b', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '$a <= $b', 'right' => true, 'question_id' => $Question->id]);
     // $this->call('UserTableSeeder');
 }
 public function index()
 {
     $fh = fopen("../resources/primary.csv", "r");
     $posts = $groups = 0;
     $connection = Connections::get('default')->connection;
     foreach (array('posts', 'groups', 'grants', 'grant_groups') as $collection) {
         $connection->{$collection}->remove(array());
     }
     while ($data = fgetcsv($fh)) {
         list($tmp, $postId, $desc, $y2011, $y2010, $y2009) = $data;
         if (!empty($tmp)) {
             /**
              * Keep track of group name
              */
             if (strpos($tmp, "Totalt") === false) {
                 $group = Group::create();
                 list($number, $name) = explode(" - ", $tmp);
                 $name = str_replace('"', "", trim($name));
                 $number = trim($number);
                 $group->save(array('name' => $name, 'number' => $number));
                 $groupId = $group->_id;
                 $groups++;
             } elseif ($group) {
                 $group->y2011 = (int) ($y2011 / 1000);
                 $group->y2010 = (int) ($y2010 / 1000);
                 $group->y2009 = (int) ($y2009 / 1000);
                 $group->save();
                 continue;
             }
         }
         /**
          * Place in previously mentioned group
          */
         if (isset($groupId)) {
             $post = Post::create();
             $post->save(array('post' => (double) $postId, 'desc' => trim($desc), 'y2011' => (int) ($y2011 / 1000), 'y2010' => (int) ($y2010 / 1000), 'y2009' => (int) ($y2009 / 1000), 'groupId' => $groupId));
             $posts++;
         }
     }
     // Grants
     return compact('groups', 'posts') + $this->grants();
 }
示例#9
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\Admin\Groups\Create $request)
 {
     $Group = Group::create($request->all());
     return redirect(route('admin.groups.list'))->with('success', "Группа {$Group->title} создана!");
 }
 public function store(CreateGroupRequest $request)
 {
     $groupType = Group::create($request->all());
     return redirect()->route('groups.index')->with('successes', ['Group created successfully']);
 }