本文整理汇总了PHP中app\Profile::whereUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::whereUserId方法的具体用法?PHP Profile::whereUserId怎么用?PHP Profile::whereUserId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Profile
的用法示例。
在下文中一共展示了Profile::whereUserId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postEditComment
public function postEditComment(CreateCommentRequest $request, $id)
{
try {
$comment = Comment::findOrFail($id);
// asume the use always has a profile.
$profile_image_name = Profile::whereUserId($request->user()->id)->pluck('profile_image_name');
if ($comment && $comment->comment_author_id == Auth::user()->id) {
$comment->body = $request->get('body');
$comment->updated_at = Carbon::now();
$comment->save();
return response()->json(array('message' => 'Your Comment has been updated', 'status' => 'success', 'body' => $comment->body, 'user_id' => Auth::id(), 'profile_image_name' => $profile_image_name, 'comment_id' => $comment->id, 'nickname' => $request->user()->nickname, 'comment_author_id' => $comment->comment_author_id));
}
} catch (ModelNotFoundException $e) {
return response()->json(array('message' => 'Unauthorized attempt to update comment', 'status' => 'failed'));
}
}
示例2: postEdit
public function postEdit(Request $request, $id)
{
//try some validation.
$rules = ['title' => 'required|min:3', 'body' => 'required'];
// validate the submitted post for editing
$this->validate($request, $rules);
$post = Post::find($id);
// if the post exist and is written by this user.
if ($post && $post->post_author_id == Auth::user()->id) {
$post->title = Input::get('title');
$post->body = Input::get('body');
$post->save();
$profile_image_name = Profile::whereUserId(Auth::id())->pluck('profile_image_name');
return response()->json(array('message' => 'Post edited', 'status' => 'success', 'title' => $post->title, 'body' => $post->body, 'profile_image_name' => $profile_image_name, 'post_id' => $post->id, 'nickname' => $request->user()->nickname, 'post_author_id' => $post->post_author_id, 'user_id' => Auth::id()));
}
return response()->json(array('message' => 'You do not have permission to edit this post', 'status' => 'Unauthorized attempt'));
}
示例3: update
/**
* Update the user's profile in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function update(Request $request)
{
$profile = Profile::whereUserId(Auth::id())->firstOrFail();
$profile->update($request->all());
return redirect('/');
}
示例4: getUserProfileImageNameByPost
public static function getUserProfileImageNameByPost($post_author_id)
{
$profile = Profile::whereUserId($post_author_id)->get()->first();
return $profile->profile_image_name;
}
示例5: getUserProfileImageNameByCommentReply
public static function getUserProfileImageNameByCommentReply($comment_reply_author_id)
{
try {
$profile = Profile::whereUserId($comment_reply_author_id)->firstOrFail();
return $profile->profile_image_name;
} catch (ModelNotFoundException $e) {
return UserController::getDefaultImageName();
}
}
示例6: getUserProfileImageName
public static function getUserProfileImageName($author_id)
{
$profile = Profile::whereUserId($author_id)->get()->first();
return is_null($profile) ? null : $profile->profile_image_name;
}