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


PHP Profile::whereUserId方法代码示例

本文整理汇总了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'));
     }
 }
开发者ID:ebrimamaubeh,项目名称:utg_bantaba,代码行数:16,代码来源:CommentController.php

示例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'));
 }
开发者ID:ebrimamaubeh,项目名称:utg_bantaba,代码行数:17,代码来源:PostController.php

示例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('/');
 }
开发者ID:guenthertheilen,项目名称:laravel-boilerplate,代码行数:12,代码来源:ProfilesController.php

示例4: getUserProfileImageNameByPost

 public static function getUserProfileImageNameByPost($post_author_id)
 {
     $profile = Profile::whereUserId($post_author_id)->get()->first();
     return $profile->profile_image_name;
 }
开发者ID:ebrimamaubeh,项目名称:utg_bantaba,代码行数:5,代码来源:Helper.php

示例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();
     }
 }
开发者ID:ebrimamaubeh,项目名称:utg_bantaba,代码行数:9,代码来源:CommentReplyController.php

示例6: getUserProfileImageName

 public static function getUserProfileImageName($author_id)
 {
     $profile = Profile::whereUserId($author_id)->get()->first();
     return is_null($profile) ? null : $profile->profile_image_name;
 }
开发者ID:ebrimamaubeh,项目名称:utg_bantaba,代码行数:5,代码来源:UserController.php


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