當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。