本文整理汇总了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'));
}
示例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'));
}
示例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]);
}
示例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()];
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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'));
}
示例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]);
}
示例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"));
}
示例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.');
}
示例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);
}
}