本文整理汇总了PHP中app\Group::users方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::users方法的具体用法?PHP Group::users怎么用?PHP Group::users使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Group
的用法示例。
在下文中一共展示了Group::users方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listUsers
public function listUsers($description)
{
if (!isset($description)) {
return "bad";
}
$group = new Group();
return $group->users($description);
}
示例2: embed
/**
* Renders a embedable map
*/
public function embed(Group $group)
{
$users = $group->users()->where('latitude', '<>', 0)->get();
$actions = $group->actions()->where('start', '>=', Carbon::now())->where('latitude', '<>', 0)->get();
// randomize users geolocation by a few meters
foreach ($users as $user) {
$user->latitude = $user->latitude + mt_rand(0, 10) / 10000;
$user->longitude = $user->longitude + mt_rand(0, 10) / 10000;
}
return view('groups.map_embed')->with('tab', 'map')->with('group', $group)->with('users', $users)->with('actions', $actions)->with('latitude', 50.8503396)->with('longitude', 4.3517103);
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['name' => 'required', 'open' => 'required|boolean', 'service_provider' => 'required|boolean', 'sites' => 'required']);
$sites = explode(',', $request->sites);
$group = new Group();
$group->name = $request->name;
$group->open = (bool) $request->open;
$group->service_provider = (bool) $request->service_provider;
if ($group->save()) {
$group->sites()->sync($sites);
$group->users()->attach(Auth::user()->id, ['permission_id' => 1]);
return $this->respondWithItem($group, new GroupTransformer());
}
}
示例4: store
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$this->validate($request, ['name' => 'required|max:64', 'scout_group' => 'required|max:64', 'age_group' => 'required|max:64']);
$group = new Group();
$group->name = $request->input('name');
$group->scout_group = $request->input('scout_group');
$group->age_group = $request->input('age_group');
$group->save();
// Jäsenet
$participants = $request->input('participants');
if (isset($participants)) {
foreach ($participants as $participant) {
$group->users()->attach($participant, ['role' => 'member']);
}
}
//Ryhmänjohtajat
$leaders = $request->input('leaders');
if (isset($leaders)) {
foreach ($leaders as $leader) {
$group->users()->attach($leader, ['role' => 'leader']);
}
}
return redirect('groups');
}
示例5: store
public function store(CreateGroupRequest $request)
{
if (Gate::denies('managerOnly')) {
abort(403);
}
$input = $request->all();
$result = DB::transaction(function ($input) use($input) {
$group = new Group();
$group->name = $input['name'];
$group->organization()->associate(Auth::user()->organization);
$group->save();
foreach ($input['users'] as $user) {
$group->users()->attach($user['id']);
}
foreach ($input['indicators'] as $indicator) {
$group->indicators()->attach($indicator['id']);
}
return $group;
});
return $result;
}
示例6: getLatestMembers
/**
* Created By Dara on 31/10/2015
* get the last 5 members
*/
public function getLatestMembers(Group $group)
{
$users = $group->users()->latest()->take(5)->get();
return $users;
}
示例7: function
/**
* POST /groups
* Create a new group and add authenticated user to it
*/
Route::post('/groups', function (Request $request) {
if (Auth::check()) {
$v = Validator::make($request->all(), ['name' => 'required|max:255']);
if ($v->fails()) {
return redirect()->back()->withInput()->withErrors($v);
}
// Create New Group
$group = new Group();
$group->name = $request->name;
$group->description = trim($request->description);
$group->save();
$group->users()->save(Auth::user());
return redirect()->back();
} else {
return redirect('/');
}
});
/**
* DELETE /group/{id}
* Delete the group corresponding to {id}
*/
Route::delete('/group/{id}', function ($id) {
if (Auth::check()) {
$group = Group::findOrFail($id);
$group->users()->where('id', '=', Auth::id())->detach();
return redirect('/groups');
} else {
示例8: leave
public function leave(Group $group, Request $request)
{
$user = Auth::user();
if ($request->user()->cannot('join-group', [$group])) {
//the user is not a member so we add him/her to the group
$group->users()->detach([$user->id]);
}
return redirect()->back();
// return[
// 'hasCallback'=>1,
// 'callback'=>'group_join',
// 'hasMsg'=>0,
// 'msg'=>'',
// 'msgType'=>'',
// 'returns'=> [
// 'status'=>'undo'
// ]
//
// ];
}