Session api token validation

This commit is contained in:
2026-06-23 11:20:01 +10:00
parent cd1538ba12
commit fcba639bae
25 changed files with 491 additions and 235 deletions
+47
View File
@@ -3,7 +3,9 @@
namespace App\Http\Controllers;
use App\Models\UserAction;
use App\Models\UserFlight;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Inertia\Inertia;
class FeedController extends Controller
@@ -28,4 +30,49 @@ class FeedController extends Controller
'feed' => $feed,
]);
}
public function following()
{
$user = auth()->user();
return Cache::remember(
"user:{$user->id}:following",
now()->addMinutes(15),
fn () => $user->following()
->with('followee')
->get()
->pluck('followee')
->filter()
->values()
->toArray()
);
}
public function followingFlights()
{
$user = auth()->user();
return Cache::remember(
"user_following_flights_{$user->id}",
now()->addDays(30),
function () use ($user) {
$followingIds = $user->following()
->with('followee')
->get()
->pluck('followee')
->filter()
->reject(fn ($followee) => ($followee->settings['profile_privacy'] ?? 'public') === 'private')
->pluck('id');
return UserFlight::query()
->with(['departureAirport', 'arrivalAirport', 'user'])
->whereIn('user_id', $followingIds)
->orderByDesc('departure_date')
->limit(100)
->get()
->values()
->toArray();
}
);
}
}