2019-08-08 06:06:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use App\{
|
|
|
|
Place,
|
|
|
|
Status
|
|
|
|
};
|
|
|
|
|
|
|
|
class PlaceController extends Controller
|
|
|
|
{
|
2022-03-31 05:56:46 +00:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->middleware('auth');
|
|
|
|
}
|
|
|
|
|
2019-08-08 06:06:31 +00:00
|
|
|
public function show(Request $request, $id, $slug)
|
|
|
|
{
|
2023-01-28 03:52:12 +00:00
|
|
|
$this->validate($request, [
|
|
|
|
'page' => 'sometimes|max:10'
|
|
|
|
]);
|
|
|
|
|
2019-08-08 06:06:31 +00:00
|
|
|
$place = Place::whereSlug($slug)->findOrFail($id);
|
|
|
|
$posts = Status::wherePlaceId($place->id)
|
2019-08-30 01:27:34 +00:00
|
|
|
->whereNull('uri')
|
2019-08-08 06:06:31 +00:00
|
|
|
->whereScope('public')
|
|
|
|
->orderByDesc('created_at')
|
2019-08-30 01:27:34 +00:00
|
|
|
->simplePaginate(10);
|
|
|
|
|
2019-08-08 06:06:31 +00:00
|
|
|
return view('discover.places.show', compact('place', 'posts'));
|
|
|
|
}
|
2019-08-30 01:27:34 +00:00
|
|
|
|
|
|
|
public function directoryHome(Request $request)
|
|
|
|
{
|
|
|
|
$places = Place::select('country')
|
|
|
|
->distinct('country')
|
|
|
|
->simplePaginate(48);
|
|
|
|
|
|
|
|
return view('discover.places.directory.home', compact('places'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function directoryCities(Request $request, $country)
|
|
|
|
{
|
2020-02-16 08:28:48 +00:00
|
|
|
$country = ucfirst(urldecode($country));
|
2019-08-30 01:27:34 +00:00
|
|
|
$places = Place::whereCountry($country)
|
|
|
|
->orderBy('name', 'asc')
|
|
|
|
->distinct('name')
|
|
|
|
->simplePaginate(48);
|
|
|
|
|
|
|
|
return view('discover.places.directory.cities', compact('places'));
|
|
|
|
}
|
2019-08-08 06:06:31 +00:00
|
|
|
}
|