Session api token validation
This commit is contained in:
@@ -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();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user