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


PHP User::with方法代码示例

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


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

示例1: updateLevel

 public function updateLevel(Request $request)
 {
     $user = User::with(['level', 'courses' => function ($query) {
         $query->where('level', '1')->where('validated', 1);
     }])->where('id', $request->id)->first();
     $oldLevel = ucfirst($user->level->name);
     if (Auth::check()) {
         if (Auth::user()->id != $user->id) {
             if (Auth::user()->level_id == 5 || Auth::user()->level_id == 4 && $user->level_id < 4) {
                 if ($request->level < 3 && $user->courses->count() > 0) {
                     Flash::error('Impossible de rétrograder cet utilisateur à ce level car il est professeur de ' . $user->courses->count() . ' cours.');
                     return Redirect::back();
                 }
                 $newLevel = ucfirst(Level::find($request->level)->name);
                 $modif = $user->level_id > $request->level ? 'downgraded' : 'upgraded';
                 $user->level_id = $request->level;
                 $user->save();
                 Flash::success('Le changement a été effectué avec succès.');
                 makeModification('users', printUserLinkV2($user) . ' as been ' . $modif . ' from ' . $oldLevel . ' to ' . $newLevel . '.');
                 return Redirect::back();
             }
         }
     }
     Flash::error('Vous n\'avez pas les droits nécéssaires pour cela.');
     return Redirect::back();
 }
开发者ID:Techraav,项目名称:PolyMusic,代码行数:26,代码来源:UserController.php

示例2: index

 public function index(User $user, $type = null)
 {
     if (!Entrust::can('manage_user')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     $query = $user->with('roles');
     if ($type != null) {
         $query->whereHas('roles', function ($qry) use($type) {
             $qry->where('name', '=', $type);
         });
     }
     $users = $query->get();
     $col_data = array();
     $col_heads = array(trans('messages.Option'), trans('messages.Name'), trans('messages.Username'), trans('messages.Email'), trans('messages.Department'), trans('messages.Role'));
     $col_heads = Helper::putCustomHeads($this->form, $col_heads);
     $col_ids = Helper::getCustomColId($this->form);
     $values = Helper::fetchCustomValues($this->form);
     $token = csrf_token();
     foreach ($users as $user) {
         foreach ($user->roles as $role) {
             $role_name = $role->display_name;
         }
         $cols = array('<div class="btn-group btn-group-xs">' . '<a href="/user/' . $user->id . '" class="btn btn-default btn-xs" data-toggle="tooltip" title="View"> <i class="fa fa-share"></i></a> ' . '<a href="/user/welcomeEmail/' . $user->id . '/' . $token . '" class="btn btn-default btn-xs" data-toggle="tooltip" title="Send Welcome Email"> <i class="fa fa-envelope"></i></a>' . '<a href="/user/' . $user->id . '/edit" class="btn btn-default btn-xs" data-toggle="tooltip" title="Edit"> <i class="fa fa-edit"></i></a> ' . delete_form(['user.destroy', $user->id]) . '</div>', $user->name, $user->username, $user->email, $user->Profile->department_id != null ? $user->Profile->Department->department_name : '', $role_name);
         $id = $user->id;
         foreach ($col_ids as $col_id) {
             array_push($cols, isset($values[$id][$col_id]) ? $values[$id][$col_id] : '');
         }
         $col_data[] = $cols;
     }
     Helper::writeResult($col_data);
     return view('user.index', compact('col_heads'));
 }
开发者ID:EneaWeb,项目名称:aliangel,代码行数:32,代码来源:UserController.php

示例3: showGroup

 public function showGroup()
 {
     $customer_id = Auth::user()->customer->id;
     $group = User::with('unpaidOrders')->where('customer_id', $customer_id)->get();
     $spendings = Customer::find($customer_id)->unpaidOrders->sum('total_price');
     return view('account.group', compact('group', 'spendings'));
 }
开发者ID:jhruby23,项目名称:barapp,代码行数:7,代码来源:AccountController.php

示例4: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $this->authorize('users-edit');
     $user = User::with('roles')->findOrFail($id);
     $roles = Role::orderBy('display_name')->get();
     return view('users.edit', compact('roles', 'user'));
 }
开发者ID:guenthertheilen,项目名称:laravel-boilerplate,代码行数:13,代码来源:UsersController.php

示例5: show

 public function show($id)
 {
     //show single
     $record = User::with($this->related)->findOrFail($id);
     $record['fullname'] = $record->fullname;
     return $record;
 }
开发者ID:RHT-Memphis,项目名称:aeroeco,代码行数:7,代码来源:UsersController.php

示例6: show

 /**
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function show(Request $request)
 {
     $questions = ProfileQuestion::join('profiles_answers', 'profiles_questions.id', '=', 'profiles_answers.profile_question_id')->where('profiles_answers.user_id', $request->id)->get();
     $user = User::with('achievements')->where('users.id', $request->id)->first();
     //$users = User::where('category_id', 2)->where('id', '<>', Auth::user()->id)->get();
     return view('members/show', ['user' => $user, 'questions' => $questions]);
 }
开发者ID:prudywsh,项目名称:tpe,代码行数:10,代码来源:MemberController.php

示例7: getAll

 public function getAll()
 {
     // return User::with('roles')->orderBy('first_name')->get();
     return User::with('roles')->whereHas('roles', function ($q) {
         $q->where('name', '!=', 'Medico')->where('name', '!=', 'Farmacista');
     })->orderBy('first_name')->get();
 }
开发者ID:sidis405,项目名称:ibi,代码行数:7,代码来源:InternalUsersRepo.php

示例8: getUserByIdWithRole

 public function getUserByIdWithRole($id)
 {
     $users = User::with('userRole')->with(['projects' => function ($q) {
         return $q->selectRaw('group_concat(projects.id) as project_ids');
     }])->find($id);
     return $users;
 }
开发者ID:arsenaltech,项目名称:folio,代码行数:7,代码来源:UserRepository.php

示例9: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     abort_unauthorized($id);
     $user = User::with('sessions')->findOrFail($id);
     $user->currentSessionHash = \App\ValidSession::generateFingerprint(request())['hash'];
     return $user;
 }
开发者ID:Orvo,项目名称:mlraamattu,代码行数:13,代码来源:UsersController.php

示例10: profile

 public function profile()
 {
     $user_id = app('auth')->user()->getKey();
     $user = User::with('wishlists', 'wishlists.givingCircle', 'wishlists.items')->where('id', '=', $user_id)->get()->first();
     js(['user' => $user->getAttributes(), 'wishlists' => $user->wishlists->toArray()]);
     return view('profile', ['user' => $user]);
 }
开发者ID:penoonan,项目名称:giving-circle,代码行数:7,代码来源:UserController.php

示例11: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $all_user_details = User::with('uploadDetail')->get();
     $users = array();
     foreach ($all_user_details as $key => $value) {
         $users[$key]['id'] = $value->id;
         $users[$key]['name'] = $value->name;
         $users[$key]['email'] = $value->email;
         $users[$key]['username'] = $value->username;
         $users[$key]['age'] = $value->age;
         $users[$key]['allow_payment'] = $value->name;
         $users[$key]['created_at'] = $value->created_at;
         foreach ($all_user_details[$key]->uploadDetail as $key1 => $value1) {
             $users[$key]['upload_detail'][$key1]['id'] = $value1->id;
             $users[$key]['upload_detail'][$key1]['user_id'] = $value1->user_id;
             $users[$key]['upload_detail'][$key1]['file_destination'] = $value1->file_destination;
             $users[$key]['upload_detail'][$key1]['file_name'] = $value1->file_name;
             $users[$key]['upload_detail'][$key1]['status'] = $value1->status;
             $users[$key]['upload_detail'][$key1]['payment_status'] = $value1->payment_status;
             $users[$key]['upload_detail'][$key1]['is_selected'] = $value1->is_selected;
             $users[$key]['upload_detail'][$key1]['season_name'] = $value1->season_name;
             $users[$key]['upload_detail'][$key1]['created_at'] = $value1->created_at->toDateTimeString();
             $users[$key]['upload_detail'][$key1]['updated_at'] = $value1->updated_at->toDateTimeString();
         }
     }
     // return $users;
     $data = array("users" => $users);
     // return $all_user_details;
     return view('users', $data);
 }
开发者ID:amitsers,项目名称:test,代码行数:35,代码来源:AdminController.php

示例12: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $users = User::with('roles')->get();
     $roles = Role::all();
     return view('rbac.user')->with(['users' => $users, 'roles' => $roles]);
     // return view('rbac.user');
 }
开发者ID:WangWeigao,项目名称:m1,代码行数:12,代码来源:RbacController.php

示例13: getEmployee

 public function getEmployee()
 {
     if (!empty($this->employee)) {
         return $this->employee;
     }
     return $this->employee = User::with('Employee')->whereId($this->user->id)->first();
 }
开发者ID:nq2916,项目名称:jot,代码行数:7,代码来源:AuthUser.php

示例14: users

 public function users()
 {
     $users = User::with('organization', 'roles')->get(['id', 'name', 'email', 'organization_id']);
     $orgs = Organization::all();
     $roles = Role::all();
     return Datatables::of($users)->addColumn('organization', function ($user) use($orgs) {
         $orgSelect = '<select name="organization" class="form-control organization" data-userid="' . $user->id . '">';
         foreach ($orgs as $org) {
             $select = "";
             if ($org->id == $user->organization_id) {
                 $select = 'selected';
             }
             $orgSelect .= '<option value="' . $org->id . '" ' . $select . '>' . $org->name . '</option>';
         }
         $orgSelect .= '</select>';
         //return '<a href="#edit-'.$user->id.'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> '.$user->organization->name.'</a>';
         return $orgSelect;
     })->addColumn('role', function ($user) use($roles) {
         $roleSelect = '<select name="organization" class="form-control role" data-userid="' . $user->id . '">';
         foreach ($roles as $role) {
             $select = "";
             if ($user->hasRole($role->name)) {
                 $select = 'selected';
             }
             $roleSelect .= '<option value="' . $role->id . '" ' . $select . '>' . $role->display_name . '</option>';
         }
         $roleSelect .= '</select>';
         //return '<a href="#edit-'.$user->id.'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> '.$user->roles[0]->display_name.'</a>';
         return $roleSelect;
     })->removeColumn('id')->removeColumn('organization_id')->make(true);
 }
开发者ID:gfdeveloper,项目名称:LCCB,代码行数:31,代码来源:ApiController.php

示例15: getAll

 public function getAll()
 {
     // Get All Users
     $users = User::with('role')->get();
     // Passing data to response service
     return $this->responseService->returnMessage($users, 'No Users were Found.');
 }
开发者ID:owemus,项目名称:personal_be,代码行数:7,代码来源:UserService.php


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