2019-07-26 10:40:56 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Models\Article;
|
|
|
|
use App\Models\Bookmark;
|
2019-10-27 16:29:15 +00:00
|
|
|
use App\Models\Like;
|
|
|
|
use App\Models\Note;
|
2019-10-27 16:15:14 +00:00
|
|
|
use App\Services\ActivityStreamsService;
|
2020-08-09 15:54:10 +01:00
|
|
|
use Illuminate\Http\Response;
|
|
|
|
use Illuminate\View\View;
|
2019-07-26 10:40:56 +01:00
|
|
|
|
|
|
|
class FrontPageController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Show all the recent activity.
|
2020-08-09 15:54:10 +01:00
|
|
|
*
|
|
|
|
* @return Response|View
|
2019-07-26 10:40:56 +01:00
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
2019-10-27 16:15:14 +00:00
|
|
|
if (request()->wantsActivityStream()) {
|
|
|
|
return (new ActivityStreamsService())->siteOwnerResponse();
|
|
|
|
}
|
|
|
|
|
2019-07-26 10:40:56 +01:00
|
|
|
$notes = Note::latest()->get();
|
|
|
|
$articles = Article::latest()->get();
|
|
|
|
$bookmarks = Bookmark::latest()->get();
|
|
|
|
$likes = Like::latest()->get();
|
|
|
|
|
2020-02-23 17:12:17 +00:00
|
|
|
$items = collect($notes)
|
2019-07-26 10:40:56 +01:00
|
|
|
->merge($articles)
|
|
|
|
->merge($bookmarks)
|
|
|
|
->merge($likes)
|
2020-02-23 17:12:17 +00:00
|
|
|
->sortByDesc('updated_at')
|
|
|
|
->paginate(10);
|
2020-02-23 12:39:21 +00:00
|
|
|
|
2019-07-26 10:40:56 +01:00
|
|
|
return view('front-page', [
|
2020-02-23 12:39:21 +00:00
|
|
|
'items' => $items,
|
2019-07-26 10:40:56 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|