2019-07-26 10:40:56 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Models\Article;
|
2023-04-11 16:16:05 +01:00
|
|
|
use App\Models\Bio;
|
2019-07-26 10:40:56 +01:00
|
|
|
use App\Models\Bookmark;
|
2019-10-27 16:29:15 +00:00
|
|
|
use App\Models\Like;
|
|
|
|
use App\Models\Note;
|
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.
|
|
|
|
*/
|
2023-06-25 14:18:40 +01:00
|
|
|
public function index(): Response|View
|
2019-07-26 10:40:56 +01:00
|
|
|
{
|
2023-11-25 16:08:07 +00:00
|
|
|
$notes = Note::latest()->with(['media', 'client', 'place'])->withCount(['webmentions AS replies' => function ($query) {
|
|
|
|
$query->where('type', 'in-reply-to');
|
|
|
|
}])
|
2023-11-25 16:12:52 +00:00
|
|
|
->withCount(['webmentions AS likes' => function ($query) {
|
|
|
|
$query->where('type', 'like-of');
|
|
|
|
}])
|
|
|
|
->withCount(['webmentions AS reposts' => function ($query) {
|
|
|
|
$query->where('type', 'repost-of');
|
|
|
|
}])->get();
|
2019-07-26 10:40:56 +01:00
|
|
|
$articles = Article::latest()->get();
|
2023-11-25 16:08:07 +00:00
|
|
|
$bookmarks = Bookmark::latest()->with('tags')->get();
|
2019-07-26 10:40:56 +01:00
|
|
|
$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
|
|
|
|
2023-04-11 16:16:05 +01:00
|
|
|
$bio = Bio::first()?->content;
|
|
|
|
|
2019-07-26 10:40:56 +01:00
|
|
|
return view('front-page', [
|
2020-02-23 12:39:21 +00:00
|
|
|
'items' => $items,
|
2023-04-11 16:16:05 +01:00
|
|
|
'bio' => $bio,
|
2019-07-26 10:40:56 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|