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;
|
2023-02-18 09:34:57 +00:00
|
|
|
use Illuminate\Http\Request;
|
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-02-18 09:34:57 +00:00
|
|
|
public function index(Request $request): Response|View
|
2019-07-26 10:40:56 +01:00
|
|
|
{
|
2022-11-24 21:44:57 +00:00
|
|
|
$notes = Note::latest()->with(['media', 'client', 'place'])->get();
|
2019-07-26 10:40:56 +01:00
|
|
|
$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
|
|
|
|
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
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|