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


PHP Group::members方法代码示例

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


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

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $group = new Group();
     $group->name = 'Projects';
     $group->officer_id = 1;
     $group->save();
     $group->members()->attach(1);
 }
开发者ID:kocsenc,项目名称:api,代码行数:13,代码来源:GroupTableSeeder.php

示例2: createGroup

 public function createGroup(Request $request)
 {
     $user = Auth::user();
     $group = new Group();
     $group->gname = $request->input('gname');
     $group->user_id = $user->id;
     $group->save();
     $group->members()->attach(array($user->id));
     //Adds user as member of group
     return Redirect::action('PagesController@dashboard');
 }
开发者ID:Jessehuze,项目名称:se-group8,代码行数:11,代码来源:PagesController.php

示例3: store

 public function store()
 {
     $rules = ['name' => 'required'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         $group = new Group(Input::only(['name', 'description']));
         $group->save();
         $memberDatas = [];
         $members = Input::has('members') ? Input::get('members') : [];
         foreach ($members as $member) {
             $memberDatas[$member] = ['is_owner' => 0];
         }
         $owners = Input::has('owners') ? Input::get('owners') : [];
         foreach ($owners as $owner) {
             $memberDatas[$owner] = ['is_owner' => 1];
         }
         $memberDatas[Auth::user()->id] = ['is_owner' => 1];
         $group->members()->sync($memberDatas);
         return Redirect::to(route('group.edit', ['groupId' => $group->id]))->with(['success_message' => 'Created!']);
     }
 }
开发者ID:nguyenvanduocit,项目名称:Password-Manager,代码行数:23,代码来源:GroupController.php

示例4: syncMembers

 /**
  * Sync list of members in the database
  *
  * @param Group $group      The group to sync members with
  * @param array $members    The members that belong in the group
  */
 public function syncMembers(Group $group, array $members)
 {
     $group->members()->sync($members);
 }
开发者ID:scify,项目名称:Vote-collector,代码行数:10,代码来源:GroupsController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $cfg = Config::first();
     // Check config if registration is enabled
     if (!$cfg->registration_enabled) {
         return response()->json(["msg" => "registrations are disabled"], 403);
     }
     $v = Validator::make($request->all(), ['name' => 'required|max:255|unique:groups', 'members' => 'required|array']);
     for ($n = 0; $n < count($request->members); $n++) {
         $v->sometimes("members.{$n}.email", 'required|email|max:255', function ($input) use($n) {
             return count($input->members >= $n);
         });
         $v->sometimes("members.{$n}.password", 'required|confirmed|min:6', function ($input) use($n) {
             return count($input->members >= $n);
         });
         $v->sometimes("members.{$n}.first_name", 'required|max:255', function ($input) use($n) {
             return count($input->members >= $n);
         });
         $v->sometimes("members.{$n}.last_name", 'required|max:255', function ($input) use($n) {
             return count($input->members >= $n);
         });
         $v->sometimes("members.{$n}.birthdate", 'required|date', function ($input) use($n) {
             return count($input->members >= $n);
         });
         $v->sometimes("members.{$n}.sex", 'required|in:m,f', function ($input) use($n) {
             return count($input->members >= $n);
         });
         $v->sometimes("members.{$n}.country", 'required', function ($input) use($n) {
             return count($input->members >= $n);
         });
         //$v->sometimes("members.$n.cv", 'required|mimes:pdf', function($input) use($n) { return count($input->members >= $n); });
     }
     $v->after(function ($validator) use($request) {
         if (count($request->members) < 1 || count($request->members) > 3) {
             $validator->errors()->add('members', 'Only 1-3 members are accepted');
         }
     });
     if ($v->fails()) {
         return response()->json($v->errors(), 400);
     }
     // validate all members have correct auth or do not exist yet
     foreach ($request->members as $m) {
         $qm = Member::where('email', $m['email']);
         if ($qm->exists()) {
             // Check password
             if (!Auth::once(['email' => $m['email'], 'password' => $m['password']])) {
                 return response()->json(["msg" => "User already exists, and password is incorrect", "offender" => $m['email']], 400);
             }
         }
     }
     $group = new Group($request->only('name'));
     $group->save();
     // create or register to the group all the members
     foreach ($request->members as $m) {
         $qm = Member::where('email', $m['email']);
         if (!$qm->exists()) {
             $qm = new Member($m);
             $qm->password = Hash::make($m['password']);
             $group->members()->save($qm);
             // Handle cv PDF
             //if ($m['cv']->isValid()) {
             //    $m['cv']->move(storage_path('app/cvs'), $qm->id.'.pdf');
             //}
         }
     }
     Mail::send('emails.admin.groupCreated', ['group' => $group], function ($m) use($group, $cfg) {
         $m->from('eca-noreply@eestec.net', 'EESTEC Android Competition');
         $m->to($cfg->admin_email, 'ECA Admin')->subject('New group registered!');
     });
     return response()->json($group);
 }
开发者ID:abada,项目名称:pleem,代码行数:77,代码来源:GroupController.php


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