當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::with方法代碼示例

本文整理匯總了PHP中app\models\User::with方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::with方法的具體用法?PHP User::with怎麽用?PHP User::with使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\User的用法示例。


在下文中一共展示了User::with方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: show

 /**
  * Displays the specified user.
  *
  * @param int|string $id
  *
  * @return \Illuminate\View\View
  */
 public function show($id)
 {
     $this->authorize('admin.users.show');
     $user = $this->user->with(['roles'])->findOrFail($id);
     $permissions = $this->presenter->tablePermissions($user);
     $formPermissions = $this->presenter->formPermissions($user);
     return view('admin.users.show', compact('user', 'permissions', 'formPermissions'));
 }
開發者ID:stevebauman,項目名稱:ithub,代碼行數:15,代碼來源:UserController.php

示例2: profile

 protected function profile(int $type, string $id_slug)
 {
     $id = unslug($id_slug)[0];
     $user = User::with('location', 'links.network', 'links')->findOrFail($id);
     $myself = \Auth::user() && \Auth::user()->id == $user->id;
     return view('user.profile', compact('id', 'type', 'user', 'myself'));
 }
開發者ID:konato-events,項目名稱:web,代碼行數:7,代碼來源:UserController.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $roles = Role::all();
     $permissions = Permission::all();
     $usersWithRoles = User::with('roles')->orderBy('last_name')->get();
     return view('admin.roles.index', ['roles' => $roles, 'permissions' => $permissions, 'users' => $usersWithRoles]);
 }
開發者ID:scotthummel,項目名稱:lambdaphx,代碼行數:12,代碼來源:RoleController.php

示例4: history

 public function history($match_id)
 {
     $since = Request::input('since', 0);
     $full = Request::input('full', false) === 'true';
     $match = Match::findOrFail($match_id);
     $events = $match->events()->with(['game.beatmap.beatmapset', 'game.scores' => function ($query) {
         $query->with('game')->default();
     }])->where('event_id', '>', $since);
     if ($full) {
         $events->default();
     } else {
         $events->orderBy('event_id', 'desc')->take(config('osu.mp-history.event-count'));
     }
     $events = $events->get();
     if (!$full) {
         $events = $events->reverse();
     }
     $userIds = [];
     foreach ($events as $event) {
         if ($event->user_id) {
             $userIds[] = $event->user_id;
         }
         if ($event->game) {
             foreach ($event->game->scores as $score) {
                 $userIds[] = $score->user_id;
             }
         }
     }
     $users = User::with('country')->whereIn('user_id', array_unique($userIds))->get();
     $users = json_collection($users, new UserCompactTransformer(), 'country');
     $events = json_collection($events, new EventTransformer(), ['game.beatmap.beatmapset', 'game.scores']);
     return ['events' => $events, 'users' => $users, 'all_events_count' => $match->events()->count()];
 }
開發者ID:ameliaikeda,項目名稱:osu-web,代碼行數:33,代碼來源:MatchesController.php

示例5: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $data['users'] = User::with('group')->get();
     $data['createbtn'] = Permission::hasPermission('users.create');
     $data['editbtn'] = Permission::hasPermission('users.edit');
     $data['deletebtn'] = Permission::hasPermission('users.delete');
     return view('users.index', $data);
 }
開發者ID:mahitiinfo,項目名稱:rubanbridge,代碼行數:13,代碼來源:UserController.php

示例6: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $site = Config::get('site');
     if ($result = check_auth_to('YHLB_INDEX')) {
         return $result;
     }
     $data['userList'] = User::with('userRole')->paginate($site['page_size']);
     return view('admin.user.index', $data);
 }
開發者ID:xinzou,項目名稱:authority_management,代碼行數:14,代碼來源:UserController.php

示例7: index

 public function index()
 {
     $users = User::with(['userEvents' => function ($query) {
         $query->where('event_id', 1);
     }])->with(['userTransactions' => function ($query) {
         $query->where('event_id', 1);
     }])->has('userEvents')->has('userTransactions')->get();
     return view('admin.users')->with('users', $users);
 }
開發者ID:aindong,項目名稱:cmnterprise-front,代碼行數:9,代碼來源:RegistrantsController.php

示例8: getHackersWithRating

 public function getHackersWithRating()
 {
     $hackers = [];
     foreach (Application::where("team_id", $this->id)->get() as $app) {
         $hacker = User::with('application', 'application.ratings', 'application.school')->find($app->user_id);
         $hacker['application']['ratinginfo'] = $hacker->application->ratingInfo();
         $hackers[] = $hacker;
     }
     return $hackers;
 }
開發者ID:BoilerMake,項目名稱:backend,代碼行數:10,代碼來源:Team.php

示例9: getUsers

 public function getUsers($limit, $skip)
 {
     //Pega todos os usuários do banco, transforma a Collection em Array para
     //ser armazenada em cache
     $users = User::with('company')->take($limit)->skip($skip)->get()->toArray();
     //Gera o slug do nome para cada usuário
     foreach ($users as $key => $user) {
         $users[$key]['name'] = explode('-', Slug::generate(strtolower($user['name'])));
     }
     return $users;
 }
開發者ID:beingsane,項目名稱:SeminarioLocaweb,代碼行數:11,代碼來源:SocketServerCommand.php

示例10: find

 /**
  * get user by id
  * @param            $id
  * @param bool|false $withRoles
  * @return array|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|null
  */
 public function find($id, $withRoles = false)
 {
     if ($withRoles) {
         $user = User::with('roles')->withTrashed()->find($id);
     } else {
         $user = User::withTrashed()->find($id);
     }
     if (!is_null($user)) {
         return $user;
     }
     return array();
 }
開發者ID:aysenli,項目名稱:laravel5-backend,代碼行數:18,代碼來源:UserRepository.php

示例11: index

 public function index()
 {
     $name = Input::get('name', '');
     $onlyActive = Input::get('only_active', '');
     $perPage = Input::get('per_page', 50);
     if ($name || $onlyActive) {
         $users = User::simpleSearch($name, $onlyActive)->with('profile')->paginate($perPage);
     } else {
         $users = User::with('profile')->paginate($perPage);
     }
     return view('admin.pages.user.list', compact('users', 'onlyActive', 'name'));
 }
開發者ID:blozixdextr,項目名稱:tuasist2,代碼行數:12,代碼來源:UserController.php

示例12: index

 function index()
 {
     $user_shokushus = User::with('user_shokushus.shokushu')->find($this->user['id']);
     $shokushus = $user_shokushus['user_shokushus'];
     $user_kinmuchi = User::with('user_kinmuchis.kinmuchi')->find($this->user['id']);
     //                return($user_kinmuchi);
     $kinmuchis = $user_kinmuchi['user_kinmuchis'];
     $user_keitais = User::with('user_keitais.keitai')->find($this->user['id']);
     $keitais = $user_keitais['user_keitais'];
     //        return ($keitais);
     return view('my.edit.edit', ['shokushus' => $shokushus, 'kinmuchis' => $kinmuchis, 'keitais' => $keitais]);
 }
開發者ID:phpwh,項目名稱:tl-job,代碼行數:12,代碼來源:EditController.php

示例13: __construct

 public function __construct()
 {
     $this->middleware('auth');
     $user_types = UserType::lists("name", "id");
     $states = State::lists("name", "id");
     $users_count = User::with("state")->latest()->get()->count();
     $universities_count = University::latest()->get()->count();
     $sos_count = SosModel::latest()->get()->count();
     $students_count = Student::latest()->get()->count();
     $companies_count = Company::latest()->get()->count();
     \View::share(compact("users_count", "universities_count", "sos_count", "states", "user_types", "students_count", "companies_count"));
 }
開發者ID:joaonzangoII,項目名稱:find_my_campuses_friend,代碼行數:12,代碼來源:UniversitiesController.php

示例14: findOrThrowException

 /**
  * @param $id
  * @param bool $withRoles
  * @return mixed
  * @throws GeneralException
  */
 public function findOrThrowException($id, $withRoles = false)
 {
     if ($withRoles) {
         $user = User::with('roles')->withTrashed()->find($id);
     } else {
         $user = User::withTrashed()->find($id);
     }
     if (!is_null($user)) {
         return $user;
     }
     throw new GeneralException('That user does not exist.');
 }
開發者ID:qloog,項目名稱:laravle5-lvyou,代碼行數:18,代碼來源:UserRepository.php

示例15: getIndex

 /**
  * Redirect to the profile page.
  *
  * @return Redirect
  */
 public function getIndex()
 {
     $user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find(Auth::user()->id);
     $userlog = $user->userlog->load('assetlog', 'consumablelog', 'assetlog.model', 'licenselog', 'accessorylog', 'userlog', 'adminlog');
     if (isset($user->id)) {
         return View::make('account/view-assets', compact('user', 'userlog'));
     } else {
         // Prepare the error message
         $error = trans('admin/users/message.user_not_found', compact('id'));
         // Redirect to the user management page
         return redirect()->route('users')->with('error', $error);
     }
 }
開發者ID:dmeltzer,項目名稱:snipe-it,代碼行數:18,代碼來源:ViewAssetsController.php


注:本文中的app\models\User::with方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。