forked from projects/thebadspace
ro
682360c140
Pagination is going to need some additional features in the near future, so it made sense to give it it's own seperate class.
99 lines
3.1 KiB
PHP
99 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Repositories\LocationRepository;
|
|
use App\Repositories\SourceRepository;
|
|
use App\Services\PaginationService;
|
|
|
|
class FrontIndexController extends Controller
|
|
{
|
|
protected $location;
|
|
protected $source;
|
|
protected $pagination;
|
|
|
|
public function __construct(
|
|
LocationRepository $locationRepository,
|
|
SourceRepository $sourceRepository,
|
|
PaginationService $paginationService
|
|
) {
|
|
$this->location = $locationRepository;
|
|
$this->source = $sourceRepository;
|
|
$this->pagination = $paginationService;
|
|
}
|
|
|
|
public function start()
|
|
{
|
|
return view('front.index', [
|
|
'count' => count($this->location->getActiveLocations()),
|
|
'sources' => count($this->source->getActive()),
|
|
'recent' => $this->location->getRecent(),
|
|
'latest_date' => $this->location->getRecent()[0]->updated_at->format('Y M d'),
|
|
'title' => "The Bad Space"
|
|
]);
|
|
}
|
|
|
|
public function indexSearch(Request $request)
|
|
{
|
|
return view('front.index', [
|
|
'count' => count($this->location->getActiveLocations()),
|
|
'sources' => count($this->source->getActive()),
|
|
'recent' => $this->location->getRecent(),
|
|
'results' => $this->location->search($request),
|
|
'terms' => $request->index_search,
|
|
'latest_date' => $this->location->getRecent()[0]->updated_at->format('Y M d'),
|
|
'title' => "Search Results",
|
|
]);
|
|
}
|
|
|
|
public function about()
|
|
{
|
|
$sources = $this->source->getActive();
|
|
return view('front.about', [
|
|
'title' => "ABOUT",
|
|
'sources' => $sources
|
|
]);
|
|
}
|
|
|
|
public function appeals()
|
|
{
|
|
return view('front.appeals', [
|
|
'title' => "LOCATION APPEALS",
|
|
]);
|
|
}
|
|
|
|
public function location(string $uuid = "1")
|
|
{
|
|
$location = $this->location->getLocation($uuid);
|
|
$sources = $this->source->getActive();
|
|
$name = "NO LOCATION FOUND";
|
|
if ($location) {
|
|
$name = $location->name;
|
|
}
|
|
return view('front.location', [
|
|
'title' => str_replace(".", " ", $name),
|
|
'location' => $location,
|
|
'actions' => $location->block_count + $location->silence_count,
|
|
'sources_count' => count($sources),
|
|
'images' => json_decode($location->images),
|
|
'updated' => $location->updated_at->format('Y M d'),
|
|
]);
|
|
}
|
|
|
|
public function listings(int $pageNum = 1)
|
|
{
|
|
$page = $this->pagination->getPage($pageNum);
|
|
|
|
return view('front.listing', [
|
|
'title' => "Listings",
|
|
'sources' => count($this->source->getActive()),
|
|
"totalPages" => $page['pageCount'],
|
|
"prev" => $page['prev'],
|
|
"next" => $page['next'],
|
|
'pageNum' => $pageNum,
|
|
'locations' => $page['locations']
|
|
]);
|
|
}
|
|
}
|