-
app/Group.php
Open in GitHubuse Illuminate\Database\Eloquent\Model; class Group extends Model { // public function users() { return $this->belongsToMany(\App\User::class, 'membership')->where('membership', '>=', \App\Membership::MEMBER)->withTimestamps()->withPivot('membership'); } // }
-
app/Http/Controllers/GroupMassMembershipController.php
Open in GitHubuse App\Group; use Illuminate\Http\Request; class GroupMassMembershipController extends Controller { public function create(Request $request, Group $group) { $this->authorize('manage-membership', $group); $members = $group->users; $notmembers = \App\User::whereNotIn('id', $members->pluck('id'))->orderBy('name')->pluck('name', 'id'); return view('membership.add') ->with('group', $group) ->with('members', $members) ->with('notmembers', $notmembers) ->with('tab', 'users'); } // }