本文整理汇总了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;
}
}
}
示例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();
}
示例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)]);
}
}
示例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));
}
}