Edit File: HomeService.php
<?php namespace App\Services; use App\Http\Resources\Api\User\IndexResource; use App\Models\Image; use App\Models\User; class HomeService { public function home() { return [ 'banners' => $this->getBanners(), 'users' => $this->getUsers(), ]; } //--------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------- // Helpers //--------------------------------------------------------------------------------------------------------------------------- protected function getUsers() { return IndexResource::collection( User::select('id', 'first_name', 'last_name', 'image', 'bio') ->when(auth()->check(), function ($query) { $query->where('id', '!=', auth()->id()); }) ->inRandomOrder() ->take(request('users_limit') ?? 5) ->get() ); } protected function getBanners() { return Image::select('image')->latest()->pluck('image')->toArray(); } }
Back to File Manager