本文整理汇总了PHP中app\Group::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::with方法的具体用法?PHP Group::with怎么用?PHP Group::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Group
的用法示例。
在下文中一共展示了Group::with方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$groups = Group::with(['users' => function ($query) {
$query->where('active', 1);
}])->orderBy('name', 'ASC')->get();
return view('index', compact('groups'));
}
示例2: index
public function index()
{
$all_groups = \App\Group::with('users')->get();
$title = 'Groups';
$html = view('admin.groups.table', compact('title', 'all_groups'))->render();
return Admin::view($html);
}
示例3: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$title = 'group';
$groups = Group::with('postsCount')->leftjoin('groups_users', 'groups_users.group_id', '=', 'groups.id')->where('groups.rowStatus', '=', 0)->where('groups.admin_id', '=', Auth::user()->induser_id)->orWhere('groups_users.user_id', '=', Auth::user()->induser_id)->where('groups.rowStatus', '=', 0)->groupBy('groups.id')->get(['groups.id', 'groups.group_name', 'groups.admin_id', 'groups.created_at']);
// $connections = Auth::user()->induser->friends->lists('fname', 'id');
return view('pages.group', compact('groups', 'title'));
}
示例4: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$group = Group::with('events')->findOrFail($id);
$users = $group->users;
return view('group', compact('group'), compact('users'));
//
}
示例5: show
/**
* Display the specified group.
*
* @Get("/{id}")
* @Transaction(
* @Response(200, body={{"id": 1, "name": "Website Committee",
* "officer_id": 1, "officer_url": "/officers/1",
* "url": "/groups/1"}}),
* @Response(404, body={"error": "not found"})
* )
* @param int $id
* @return Response
*/
public function show($id)
{
try {
$group = Group::with('officer')->findOrFail($id);
return response()->json($group);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => 'not found'], Response::HTTP_NOT_FOUND);
}
}
示例6: getAll
public function getAll()
{
$groups = Group::with('posts')->orderBy('updated_at', 'desc')->paginate(10);
foreach ($groups as $key => $group) {
if (empty($group->pic)) {
$groups[$key]->pic = asset(env('LOGO'));
}
}
return $groups;
}
示例7: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
$title = 'links';
$user = Induser::with('user')->where('id', '=', Auth::user()->induser_id)->first();
$linksCount = Connections::where('user_id', '=', Auth::user()->induser_id)->where('status', '=', 1)->orWhere('connection_user_id', '=', Auth::user()->induser_id)->where('status', '=', 1)->count('id');
$linkrequestCount = Connections::where('connection_user_id', '=', Auth::user()->induser_id)->where('status', '=', 0)->count('id');
$followCount = Follow::Where('individual_id', '=', Auth::user()->induser_id)->count('id');
$linkFollow = Corpuser::with('posts')->leftjoin('follows', 'corpusers.id', '=', 'follows.corporate_id')->where('follows.individual_id', '=', Auth::user()->induser_id)->get(['corpusers.id', 'corpusers.firm_name', 'corpusers.firm_type', 'corpusers.emp_count', 'corpusers.logo_status', 'corpusers.operating_since', 'corpusers.city', 'follows.corporate_id', 'follows.individual_id']);
$groups = Group::with('postsCount')->leftjoin('groups_users', 'groups_users.group_id', '=', 'groups.id')->where('groups.rowStatus', '=', 0)->where('groups.admin_id', '=', Auth::user()->induser_id)->orWhere('groups_users.user_id', '=', Auth::user()->induser_id)->where('groups.rowStatus', '=', 0)->groupBy('groups.id')->get(['groups.id', 'groups.group_name', 'groups.admin_id', 'groups.created_at']);
return view('pages.connections', compact('title', 'user', 'linkFollow', 'linksCount', 'linkrequestCount', 'followCount', 'groups'));
}
示例8: teamsCsv
public function teamsCsv()
{
if (Gate::denies('admin')) {
Auth::logout();
return redirect('/admin/login');
}
$teams = Group::with('idea')->get();
$columns = ['id', 'name', 'created_at', 'idea.name', 'idea.repository', 'idea.description', 'idea.created_at'];
$headers = ['ID', 'Name', 'Registered At', 'Idea Name', 'Idea Repository', 'Idea Description', 'Idea Registered At'];
$csv = $this->exportCsv($teams, $columns, $headers);
$csvName = 'eca-teams-' . date('Y-m-d-His') . '.csv';
return response($csv, 200, ['Content-type' => 'text/csv', 'Content-Disposition' => sprintf('attachment; filename="%s"', $csvName), 'Content-Length' => strlen($csv)]);
}
示例9: my
public function my()
{
$groups = \App\Group::with('membership')->orderBy('name')->paginate(50);
$my_groups = Auth::user()->groups()->orderBy('name')->get();
$my_groups_id = false;
// using this array we can adjust the queries after to only include stuff the user has
// might be a good idea to find a clever way to build this array of groups id :
foreach ($my_groups as $the_group) {
$my_groups_id[] = $the_group->id;
}
$my_discussions = \App\Discussion::with('userReadDiscussion', 'user', 'group')->whereIn('group_id', $my_groups_id)->orderBy('updated_at', 'desc')->paginate(10);
$my_actions = \App\Action::with('user', 'group')->whereIn('group_id', $my_groups_id)->where('start', '>=', Carbon::now())->orderBy('start', 'asc')->paginate(10);
$other_discussions = \App\Discussion::with('userReadDiscussion', 'user', 'group')->whereNotIn('group_id', $my_groups_id)->orderBy('updated_at', 'desc')->paginate(10);
$other_actions = \App\Action::with('user', 'group')->whereNotIn('group_id', $my_groups_id)->where('start', '>=', Carbon::now())->orderBy('start', 'asc')->paginate(10);
return view('dashboard.my')->with('groups', $groups)->with('my_groups', $my_groups)->with('my_discussions', $my_discussions)->with('my_actions', $my_actions)->with('other_actions', $other_actions)->with('other_discussions', $other_discussions);
}
示例10: update
public function update($groupId)
{
$rules = ['name' => 'required'];
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$group = Group::with(['owners', 'members'])->findOrFail($groupId);
$this->authorize('update', $group);
$group->name = Input::get('name');
$group->description = Input::get('description');
$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];
}
$group->members()->sync($memberDatas);
$group->save();
return Redirect::back()->with(['success_message' => 'Updated!']);
}
示例11: findByName
/**
* find group with users by group name
*
* @param [type] $name [description]
* @return [type] [description]
*/
public function findByName($name)
{
return Group::with('users')->where('name', $name)->first();
}
示例12: show
public function show($id)
{
$group = Group::with('users', 'indicators')->find($id);
$this->authorize($group);
return $group;
}
示例13: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index($groupId)
{
$group = Group::with('members')->findOrFail($groupId);
return response()->json($group->members);
}
示例14: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$group = Group::with('members')->with('scores')->with('idea')->findOrFail($id);
return response()->json($group);
}
示例15: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$profiles = Group::with('user')->find(1)->toJson();
var_dump($profiles);
}