在我目前的系統中,用戶可以爲產品撰寫評論。防止用戶對產品提交多個評論
下面是其中的審查驗證,並創造發生在我的控制器的方法:
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