"getAllLikers"의 제한값에 도달하면 중지되고 "Illuminate \ Database \ Eloquent \ Builder 클래스의 개체를 문자열로 변환 할 수 없습니다"오류가 발생합니다. Laravel에서 4.2.11. 나는 rtconner (https://github.com/rtconner/laravel-likeable)에 의해 Likable 플러그인을 사용하고 있습니다. 좋아하는 사람이 한도를 초과하거나 초과하면 제대로 작동하지만 정확한 금액이면 작동하지 않습니다.Laravel 4 범위가 정확한 크기로 작동하지 않습니다.
나는이 문제를 해결하기 위해 여러 가지 시도를 해봤지만 제대로 작동하지 않는 것처럼 보입니다. 나는 또한 그것을 볼 친구가 있고 그는 해결책을 찾지 않았다.
나에게 어떤 제안이 있으십니까?
블레이드 템플릿 : 아래 코드를 참조
<h3 class="text-muted"><small>{{ Model::getLikers($id) }} like this.</small></h3>
모델 :
public function scopeGetLikers($query, $id) {
$info = DB::table('likeable_likes')->where('likable_type', '=', 'Model')->where('likable_id', '=', $id)->get();
$totallikes = DB::table('likeable_like_counters')->where('likable_type', '=', 'Model')->where('likable_id', '=', $id)->sum('count');
if($info == null) {
return 'No one';
}
$person = '';
$comma = '';
$int = 0;
$limit = 1;
foreach($info as $liker) {
if($int == 0) {
$comma = '';
} else {
$comma = ', ';
}
if($int <= $limit) {
$person = $person . $comma . User::getUsernameByID($liker->user_id);
}
$int++;
}
if($int > $limit) {
return $person . ' and <a href="" id="likes" tabindex="0" role="button" data-toggle="popover" data-trigger="focus" data-content="'. Model::getAllLikers($id) . '">' . ($totallikes - $limit - 1) . ' others </a> ';
}
return $person;
}
public function scopeGetAllLikers($query, $id) {
$info = DB::table('likeable_likes')->where('likable_type', '=', 'Model')->where('likable_id', '=', $id)->get();
if($info == null) {
return '9999999';
}
$person = '';
$comma = '';
$int = 0;
$limit = 2;
foreach($info as $liker) {
if($int = $limit) {
$comma = '';
} else {
$comma = ', ';
}
if($int > $limit) {
$person = $person . $comma . User::getUsernameByID($liker->user_id);
}
$int++;
}
return $person;
}