当我调用此控制器以保存用户在目录中的每个样式上选择的评级时,我一直收到此错误,这与我之前询问的如何将十进制保存到表行(Question的问题有关。 )
helpers.php第747行中的ErrorException: 方法App \ Wasamar \ Rating :: __ toString()必须返回字符串值
MY CONTROLLER
public function styleRating(){
$allInputs = Input::all();
$catalogueStyleId = Input::get('catalogueStyleId');
$userId = Crypt::decrypt( Input::get('user') );
$rating = Input::get('rating'); // value: 0.1 - 4.9
$countUserStyleRating = count( Rating::where('catalogue_style_id',$catalogueStyleId)->where('user_id','=', $userId)->first() );
if ( $countUserStyleRating == 0 ) {
# add new rating data
$rating = new Rating;
$rating->user_id = $userId;
$rating->catalogue_style_id = $catalogueStyleId;
$rating->catalogue_style_rating = $rating;
$rating->save();
echo "Your rating has been noted thank you";
}else{
if ( $countUserStyleRating == 1 ) {
# update rating data
$UserStyleRating = Rating::where('catalogue_style_id',$catalogueStyleId)->where('user_id','=', $userId)->first();
$rating = $UserStyleRating;
$rating->user_id = $userId;
$rating->catalogue_style_id = $catalogueStyleId;
$rating->catalogue_style_rating = $rating;
$rating->save();
echo "Your rating has been noted thank you";
}
}
}