本文整理汇总了PHP中Rating::destroy方法的典型用法代码示例。如果您正苦于以下问题:PHP Rating::destroy方法的具体用法?PHP Rating::destroy怎么用?PHP Rating::destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rating
的用法示例。
在下文中一共展示了Rating::destroy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
/**
* Remove the specified rating from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
Rating::destroy($id);
return Redirect::route('ratings.index');
}
示例2: testGetWineDetailNoRatingOtherUser
public function testGetWineDetailNoRatingOtherUser()
{
$this->setUpRating();
$this->setUpCountry();
$this->setUpWineNote();
$this->setUpProfile();
$rate_user1 = Rating::destroy(2);
$rate_user2 = Rating::destroy(3);
$response = $this->call('GET', 'api/wine/1');
$wine_infor = Wine::where('wine_id', 1)->with('winery')->first();
$country_name = Country::where('id', $wine_infor->winery->country_id)->first()->country_name;
$wine_note = Winenote::where('wine_unique_id', $wine_infor->wine_unique_id)->where('user_id', $this->_user_id)->first();
if ($wine_infor->wine_type != null) {
$wine_infor->wine_type = Wine::getWineType($wine_infor->wine_type);
}
$wine_infor->winenote = $wine_note->note;
$wine_infor->winery->country_id = $country_name;
$wishlist = Wishlist::where('user_id', $this->_user_id)->where('wine_unique_id', $wine_infor->wine_unique_id)->first();
if ($wishlist) {
$wine_infor->is_wishlist = true;
} else {
$wine_infor->is_wishlist = false;
}
$all_wines_winery = Wine::where('winery_id', $wine_infor->winery_id)->whereNotIn('wine_id', [1])->take(10)->get();
$wine_infor->winery->count_wine = count($all_wines_winery) + 1;
$rate_winery = $wine_infor->rate_count;
if (count($all_wines_winery) !== 0) {
$sum_rate_winery = $wine_infor->average_rate;
foreach ($all_wines_winery as $wine_winery) {
$wine_on_winery = Wine::where('wine_id', $wine_winery->wine_id)->first();
$rate_count = $wine_on_winery->rate_count;
$rate_winery = $rate_winery + $rate_count;
$average_rate = $wine_on_winery->average_rate;
$sum_rate_winery = $sum_rate_winery + $average_rate;
}
$wine_infor->winery->total_rate = $rate_winery;
$wine_infor->winery->average_rate_winery = $sum_rate_winery / count($all_wines_winery);
} else {
$wine_infor->winery->total_rate = $rate_winery;
$wine_infor->winery->average_rate_winery = $wine_infor->average_rate;
}
$rating_user = Rating::where('wine_unique_id', $wine_infor->wine_unique_id)->where('user_id', $this->_user_id)->with('profile')->first();
$wine_infor->total_like = $rating_user->like_count;
if ($rating_user->profile->image != null) {
$rating_user->profile->image = URL::asset($rating_user->profile->image);
}
$rating = Rating::where('wine_unique_id', $wine_infor->wine_unique_id)->whereNotIn('user_id', [$this->_user_id])->with('profile')->get();
if (count($rating) == 0) {
$rating = array();
}
if ($wine_infor->image_url != null) {
$wine_infor->image_url = URL::asset($wine_infor->image_url);
}
if ($wine_infor->wine_flag != null) {
$wine_infor->wine_flag = URL::asset($wine_infor->wine_flag);
}
$data = array('wine' => $wine_infor->toArray(), 'rate_user' => $rating_user->toArray(), 'rate' => $rating, 'wine_related' => $all_wines_winery->toArray());
$this->assertEquals(array("code" => ApiResponse::OK, "data" => $data), json_decode($response->getContent(), true));
}
示例3: destroy
/**
* Remove the specified rating from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$userId = Auth::user()->id;
$ratingData = Rating::find($id);
if ($userId === $ratingData["user_id"]) {
Log::info($userId);
}
if ($userId === $id) {
$ratingData = Rating::find($id);
}
if ($userId === $ratingData["user_id"]) {
Rating::destroy($id);
Log::info("rating id: {$id} deleted");
return Redirect::route('ratings.index');
} else {
return "Access Denied: this is not your rating.";
}
}
示例4: destroy
/**
* Remove the specified beer from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$ratings = Rating::where('beer_id', '=', $id)->get();
foreach ($ratings as $rating) {
Rating::destroy($rating->rating_id);
}
Beer::destroy($id);
return Response::json(['all good' => $id]);
}