本文整理汇总了PHP中app\Profile::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::with方法的具体用法?PHP Profile::with怎么用?PHP Profile::with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Profile
的用法示例。
在下文中一共展示了Profile::with方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$profiles = Profile::with('playlists')->where('user_id', 1)->first();
$playlist = $profiles->playlists->filter(function ($playlist) use($id) {
return (int) $playlist->id === (int) $id;
})->first();
return response()->json(['playlist' => $playlist]);
}
示例2: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show(Profile $profile)
{
$profiles = $profile->with('user')->paginate(15);
return view('profiles.show', compact('profile', 'profiles'));
}
示例3: index
public function index()
{
$profiles = Profile::with(['owner', 'posts', 'logo', 'hero'])->latest()->get();
return view('profiles.index', compact('profiles'));
}
示例4: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
return response()->json(['profile' => Profile::with('playlists')->where('id', $id)->first()]);
}
示例5: show
/**
* Allow Admin to see specific profile
*
* @param $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function show($id)
{
$is_admin = Auth::user()->is_admin;
$user_id = Auth::user()->id;
$profile = Profile::with('user')->where('id', '=', $id)->first();
$nulls = 0;
$no_val_html = '<a href="#myProfileModal" data-toggle="modal" role="button"><span class="glyphicon glyphicon-question-sign text-danger"></span></a>';
$profile_usr = null;
/*dd($profile);*/
if ($profile['attributes']) {
$prof_attrs = count($profile['attributes']) - 4;
foreach ($profile['attributes'] as $attr) {
if ($attr == null) {
$nulls += 1;
}
}
$profile_usr = $profile['attributes']['user_id'];
$nulls = number_format(($prof_attrs - $nulls) / $prof_attrs * 100, 0);
}
if (($user_id == $profile_usr || $is_admin) && $profile) {
return view('profile.show', ['profile' => $profile, 'nulls' => $nulls, 'no_val' => $no_val_html]);
}
abort(401, 'Unauthorized request.');
}
示例6: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$profile = Profile::with('users')->where('user_id', '=', $id)->first();
return view('profile.fullProfile', compact('profile'));
}
示例7: edit
public function edit($id)
{
$profile = Profile::with('user')->findOrFail($id);
return view('admin.profiles.edit')->with(compact('profile'));
}
示例8: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id = null)
{
$user = Auth::user();
$profile = Profile::with('user')->where('id_user', '=', $user->id)->first();
return view('profile.detail', compact('profile'));
}