File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,7 +19,15 @@ public static function middleware()
1919
2020 public function index ()
2121 {
22- return Post::with (['user ' , 'comments.user ' , 'likes ' ])->latest ()->get ();
22+ return Post::with (['user ' , 'comments.user ' , 'likes ' ])
23+ ->withCount ('likes ' )
24+ ->latest ()
25+ ->get ()
26+ ->map (function ($ post ) {
27+ return array_merge ($ post ->toArray (), [
28+ 'likes_count ' => $ post ->likes_count
29+ ]);
30+ });
2331 }
2432
2533 public function store (Request $ request )
Original file line number Diff line number Diff line change 11<?php
22
3- // use Illuminate\Support\Facades\Route;
4- // use Inertia\Inertia;
3+ use Illuminate \Support \Facades \Route ;
4+ use Inertia \Inertia ;
55
6- // Route::get('/', function () {
7- // return Inertia::render('welcome');
8- // })->name('home');
6+ Route::get ('/ ' , function () {
7+ return Inertia::render ('welcome ' );
8+ })->name ('home ' );
99
10- // Route::middleware(['auth', 'verified'])->group(function () {
11- // Route::get('dashboard', function () {
12- // return Inertia::render('dashboard');
13- // })->name('dashboard');
14- // });
10+ Route::middleware (['auth ' , 'verified ' ])->group (function () {
11+ Route::get ('dashboard ' , function () {
12+ return Inertia::render ('dashboard ' );
13+ })->name ('dashboard ' );
14+ });
1515
16- // require __DIR__.'/settings.php';
17- // require __DIR__.'/auth.php';
16+ require __DIR__ .'/settings.php ' ;
17+ require __DIR__ .'/auth.php ' ;
You can’t perform that action at this time.
0 commit comments