我正在尝试在视图页面上显示与用户连接的所有成员。就像这样View
:
<div class="row form-group" style="padding-left: 50px;">
<?php $i=0 ?>
@foreach( $friends as $friend )
<?php $member = Extras::getUserInfo($friend->user_id); $i++; ?>
@if ( Auth::user()->user_id != $member->user_id )
<input type="checkbox" id="cb{{$i}}" value="{{ $member->user_id }}" name="mem[]">
<label class="col-md-5 boxed" for="cb{{$i}}">
<p>{{isset($member->first_name) ? $member->first_name: '' ." ". isset($member->last_name) ? $member->last_name: ''}}</p>
{{isset($member->email) ? $member->email: ''}}
</label>
<div class="col-md-1"></div>
@endif
@endforeach
</div>
我正在使用此controller
。这不是我的代码,所以我真的不知道如何使用它们。
public function showFriends($account, $group) {
$gdata = \App\Group::where('alias', 'LIKE', $group)->get();
$group = $gdata[0];
$event_group = \App\EventGroup::find(EUser::getEUserEGroupID(Auth::user()->user_id, $group->group_id));
$friends = '';
if ( $event_group) {
$friends = EventGroupMembers::where('eg_id', '=', $event_group->eg_id)->get();
}
}
这是getEUserEGroupID
public function getEUserEGroupID($user_id, $gid){
$egs = \App\EventGroup::where('group_id', '=', $gid)->get();
if($egs->count() > 0){
foreach ($egs as $eg){
$data = \App\EventGroupMembers::where("user_id", "=", $user_id)->where("eg_id", "=", $eg->eg_id)->get();
if($data->count() > 0){
return $data[0]->eg_id;
}
}
}
return 0;
}