|
@@ -3,9 +3,8 @@
|
|
namespace App\Http\Controllers;
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
use App\Place;
|
|
use App\Place;
|
|
|
|
+use App\Services\PlaceService;
|
|
use App\Services\StatusService;
|
|
use App\Services\StatusService;
|
|
-use App\Status;
|
|
|
|
-use Cache;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
class PlaceController extends Controller
|
|
class PlaceController extends Controller
|
|
@@ -17,25 +16,19 @@ class PlaceController extends Controller
|
|
$this->middleware('auth');
|
|
$this->middleware('auth');
|
|
}
|
|
}
|
|
|
|
|
|
- public function show(Request $request, $id, $slug)
|
|
|
|
|
|
+ public function show(Request $request, int $id, $slug)
|
|
{
|
|
{
|
|
|
|
+ abort_if($id < 1 || $id > 128800, 404);
|
|
|
|
+
|
|
$place = Place::whereSlug($slug)->findOrFail($id);
|
|
$place = Place::whereSlug($slug)->findOrFail($id);
|
|
|
|
|
|
- $statusIds = Cache::remember(self::PLACES_CACHE_KEY.$place->id, now()->addMinutes(40), function () use ($place) {
|
|
|
|
- return Status::select('id')
|
|
|
|
- ->wherePlaceId($place->id)
|
|
|
|
- ->whereScope('public')
|
|
|
|
- ->whereIn('type', ['photo', 'photo:album', 'video'])
|
|
|
|
- ->orderByDesc('id')
|
|
|
|
- ->limit(50)
|
|
|
|
- ->get();
|
|
|
|
- });
|
|
|
|
|
|
+ $statusIds = PlaceService::getStatusesByPlaceId($id);
|
|
|
|
|
|
$posts = $statusIds->map(function ($item) {
|
|
$posts = $statusIds->map(function ($item) {
|
|
return StatusService::get($item->id);
|
|
return StatusService::get($item->id);
|
|
})->filter(function ($item) {
|
|
})->filter(function ($item) {
|
|
return $item && count($item['media_attachments'][0]);
|
|
return $item && count($item['media_attachments'][0]);
|
|
- })->take(18)->values();
|
|
|
|
|
|
+ })->take(108)->values();
|
|
|
|
|
|
return view('discover.places.show', compact('place', 'posts'));
|
|
return view('discover.places.show', compact('place', 'posts'));
|
|
}
|
|
}
|