如何在 laravel 中集成 getstream
How to integrate getstream in laravel
我正在尝试在 laravel 中设置 getstream。他们的教程对我个人帮助不是很大,我觉得已经很老了。我该如何设置模型,现在我只想让用户看到他和他的朋友发表的帖子,就这么简单。请帮我。谢谢
<?php
namespace App\Http\Controllers;
use App\Follow;
use Auth;
use App;
use Illuminate\Http\Request;
class FollowController extends Controller {
/**
* Let current user follow user $target_id
*
* @return Response
*/
public function store(Request $request)
{
$target_id = $request->target;
$user_id = Auth::id();
$params = array(
'user_id' => Auth::id(),
'target_id' => $target_id,
);
$follow = Follow::withTrashed($params)->where($params)->first();
if ($follow === null) {
$follow = new Follow($params);
$follow->save();
FeedManager::followUser($follow->user_id, $follow->target_id);
} elseif ($follow->trashed()){
$follow->restore();
FeedManager::followUser($follow->user_id, $follow->target_id);
}
return Redirect::to(Input::get('next'));
}
public function destroy($resource)
{
$follow = Follow::firstOrNew(array(
'id' => $resource,
'user_id' => Auth::id()
)
);
if ($follow->id !== null) {
$manager = App::make('feed_manager');
FeedManager::unfollowUser($follow->user_id, $follow->target_id);
$follow->delete();
}
return Redirect::to(Input::get('next'));
}
}
您似乎遗漏了此处概述的一些设置步骤:https://github.com/GetStream/Stream-Laravel(Stream-Laravel 包)
特别针对您的错误消息,您的应用似乎没有配置 FeedManager facade。
我正在尝试在 laravel 中设置 getstream。他们的教程对我个人帮助不是很大,我觉得已经很老了。我该如何设置模型,现在我只想让用户看到他和他的朋友发表的帖子,就这么简单。请帮我。谢谢
<?php
namespace App\Http\Controllers;
use App\Follow;
use Auth;
use App;
use Illuminate\Http\Request;
class FollowController extends Controller {
/**
* Let current user follow user $target_id
*
* @return Response
*/
public function store(Request $request)
{
$target_id = $request->target;
$user_id = Auth::id();
$params = array(
'user_id' => Auth::id(),
'target_id' => $target_id,
);
$follow = Follow::withTrashed($params)->where($params)->first();
if ($follow === null) {
$follow = new Follow($params);
$follow->save();
FeedManager::followUser($follow->user_id, $follow->target_id);
} elseif ($follow->trashed()){
$follow->restore();
FeedManager::followUser($follow->user_id, $follow->target_id);
}
return Redirect::to(Input::get('next'));
}
public function destroy($resource)
{
$follow = Follow::firstOrNew(array(
'id' => $resource,
'user_id' => Auth::id()
)
);
if ($follow->id !== null) {
$manager = App::make('feed_manager');
FeedManager::unfollowUser($follow->user_id, $follow->target_id);
$follow->delete();
}
return Redirect::to(Input::get('next'));
}
}
您似乎遗漏了此处概述的一些设置步骤:https://github.com/GetStream/Stream-Laravel(Stream-Laravel 包)
特别针对您的错误消息,您的应用似乎没有配置 FeedManager facade。