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


PHP Comment::whereId方法代码示例

本文整理汇总了PHP中app\Comment::whereId方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::whereId方法的具体用法?PHP Comment::whereId怎么用?PHP Comment::whereId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Comment的用法示例。


在下文中一共展示了Comment::whereId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteDelete

 /**
  * delete comment
  * @author  Tran Van Moi
  * @since  2015/05/20    	
  * @return int
  */
 public function deleteDelete()
 {
     $data = Input::all();
     $rules = ['cmt_id' => 'required|exists:comments,id'];
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         return 404;
     } else {
         $check_role_cmt = Comment::whereId($data['cmt_id'])->whereDelete_status(0)->first();
         $check_role_post = Post::whereUser_id(Auth::user()->id)->whereId($check_role_cmt->post_id)->first();
         if ($check_role_cmt->user_id == Auth::user()->id || $check_role_post) {
             $check_role_cmt->delete_status = 1;
             $check_role_cmt->save();
             return 200;
         } else {
             return 404;
         }
     }
 }
开发者ID:ambarsetyawan,项目名称:laravel-1,代码行数:25,代码来源:CommentController.php

示例2: authorize

 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     $commentId = $this->route('comment');
     $user = JWTAuth::parseToken()->authenticate();
     return Comment::whereId($commentId)->whereUserId($user->id)->exists();
 }
开发者ID:bluecipherz,项目名称:bczapi,代码行数:11,代码来源:DeleteCommentRequest.php

示例3: remove

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function remove($id)
 {
     if (Auth::check()) {
         $comment = Comment::whereId($id)->first();
         if ($comment === null) {
             $ad_id = Request::input('ad');
         } else {
             $ad_id = $comment->ad_id;
             $user_id = Auth::user()->id;
             if ($user_id == $comment->author_id || $user_id == $comment->ad->author->id) {
                 $comment->delete();
             }
         }
         return view('sub.comments', ['ad' => Ad::getById($ad_id), 'comments' => Comment::getByAdId($ad_id)]);
     }
 }
开发者ID:elberd,项目名称:maoh,代码行数:22,代码来源:CommentController.php

示例4: update

 public function update(Request $request)
 {
     $pk = $request->input('pk');
     $comment = Input::get('value');
     $commentData = Comment::whereId($pk)->first();
     $commentData->comment = $comment;
     if ($commentData->save()) {
         return Response::json(array('status' => 1));
     } else {
         return Response::json(array('status' => 0));
     }
 }
开发者ID:ReyRodriguez,项目名称:laravel-reddit,代码行数:12,代码来源:CommentController.php


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