在我目前的系统中,用户可以为产品撰写评论。防止用户对产品提交多个评论
下面是其中的审查验证,并创造发生在我的控制器的方法:
public function PostAndValidate($id)
{
$input = [
'comment' => Input::get('comment'),
'rating' => Input::get('rating')
];
$review = new Review;
$validator = Validator::make($input, $review->getCreateRules());
return to product page with error message
if ($validator->passes()) {
$review->storeReviewForBook($id, $input['comment'], $input['rating']);
return Redirect::to('book/'.$id.'#reviews-anchor')->with('review_posted',true);
}
return Redirect::to('book/'.$id.'#reviews-anchor')->withErrors($validator)->withInput();
}
如何防止用户张贴一本书或产品新的评论,他(或她)已经审查?
可以显示审查,书籍和用户的数据库结构吗? – Gokigooooks
数据库结构up – fido