Getstream Laravel 패키지를 사용하여 작은 프로젝트를 만들고 있습니다. 그러나 새 추종자에게 알림을 표시하는 데 문제가 있습니다. 컨트롤러 메서드에서 \FeedManager::getNotificationFeed($request->user()->id)->getActivities()
을 호출하면 빈 결과 집합이 나타납니다. 내 follow
모델은 다음과 같이보고했다 : 새로운이 같은 모습은 다음에 대한 stream-laravel을 사용할 때 새 소식 알림 피드를 가져 오는 데 문제가 발생했습니다.
class Follow extends Model
{
protected $fillable = ['target_id'];
public function user()
{
return $this->belongsTo(User::class);
}
public function target()
{
return $this->belongsTo(User::class);
}
public function activityNotify()
{
$targetFeed = \FeedManager::getNotificationFeed($this->target->id);
return array($targetFeed);
}
}
그런 다음 컨트롤러 액션이 알림을 얻을 :
public function notification(Request $request)
{
$feed = \FeedManager::getNotificationFeed($request->user()->id);
dd($feed->getActivities());
$activities = $feed->getActivities(0,25)['results'];
return view('feed.notifications', [
'activities' => $activities,
]);
}
사용자 모델에서을 나는 사용자가 해당 관계를 정의 많은 사람들이있다. 그리고 마지막으로이 같은 FollowController
모양에 따라 관심 등록 해제 조치 :
public function follow(Request $request)
{
// Create a new follow instance for the authenticated user
// This target_id will come from a hidden field input after clicking the
// follow button
$request->user()->follows()->create([
'target_id' => $request->target_id,
]);
\FeedManager::followUser($request->user()->id, $request->target_id);
return redirect()->back();
}
public function unfollow($user_id, Request $request)
{
$follow = $request->user()->follows()->where('target_id', $user_id)->first();
\FeedManager::unfollowUser($request->user()->id, $follow->target_id);
$follow->delete();
return redirect()->back();
}
이 내가 왼쪽으로 뭔가하지만 알림 피드에 대한 결과를 얻을 수없는 경우에 확실하지. 스트림 대시 보드에서 탐색 탭으로 이동하면 타임 라인 및 타임 라인 집합 형식의 피드를 생성하는 두 가지 새로운 기능을 사용할 수 있습니다. 또는 컨트롤러 작업에서 알림 피드를 어떻게 받아야합니까? 미리 감사드립니다.
돌아와 줘서 고마워. 좋습니다.이 방법을 시도했지만 대상 알림 슬러그로 '알림'을 설정하면 { "target": [ "유형 알림 피드가 아닌 단조로운 피드 만 볼 수 있습니다"}}. 또한 올바른 경로에 있는지 확인하기 위해 코드의 라인을 따라가는 관계를 따르는 관계자가 컨트롤러의 메소드를 따르게됩니까? –
@ChristopherVundi 죄송합니다. 주위에 요청을 작성했습니다. –
안녕하세요, 공유 한 코드 줄을 업데이트했습니다. 'FollowController'의'follow' 메쏘드 안에 두었습니다. 그러나'FeedSController' 내부의'notification' 메쏘드에서'\ FeedManager :: getNotificationFeed ($ request-> user() -> id) -> getActivities()'를 호출하면 빈 결과 집합이 리턴됩니다. 제가 잘못하고있는 일이 있습니까? 내 코드는 정확히 위와 같습니다. –