2023-08-14 13:33:53 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2023-08-21 12:56:26 -07:00
|
|
|
use Illuminate\Http\Request;
|
2024-02-09 14:53:08 -06:00
|
|
|
use App\Repositories\LocationRepository;
|
2024-02-19 13:30:00 -06:00
|
|
|
use App\Repositories\SourceRepository;
|
2023-08-14 13:33:53 -07:00
|
|
|
|
|
|
|
class FrontIndexController extends Controller
|
|
|
|
{
|
2024-02-19 13:30:00 -06:00
|
|
|
protected $location;
|
|
|
|
protected $source;
|
2023-08-17 19:50:38 -07:00
|
|
|
|
2024-02-19 13:30:00 -06:00
|
|
|
public function __construct(
|
|
|
|
LocationRepository $locationRepository,
|
|
|
|
SourceRepository $sourceRepository
|
|
|
|
) {
|
|
|
|
$this->location = $locationRepository;
|
|
|
|
$this->source = $sourceRepository;
|
2024-01-23 12:04:52 -06:00
|
|
|
}
|
2024-01-22 13:45:11 -06:00
|
|
|
|
2024-01-23 12:04:52 -06:00
|
|
|
public function start()
|
|
|
|
{
|
2023-08-17 15:14:01 -07:00
|
|
|
return view('front.index', [
|
2024-02-19 13:30:00 -06:00
|
|
|
'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'),
|
2024-01-26 12:16:38 -06:00
|
|
|
'title' => "The Bad Space"
|
2023-08-18 14:34:53 -07:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2023-08-21 12:56:26 -07:00
|
|
|
public function indexSearch(Request $request)
|
|
|
|
{
|
|
|
|
return view('front.index', [
|
2024-02-19 13:30:00 -06:00
|
|
|
'count' => count($this->location->getActiveLocations()),
|
|
|
|
'sources' => count($this->source->getActive()),
|
|
|
|
'recent' => $this->location->getRecent(),
|
|
|
|
'results' => $this->location->search($request),
|
2024-02-09 14:53:08 -06:00
|
|
|
'terms' => $request->index_search,
|
2024-02-19 13:30:00 -06:00
|
|
|
'latest_date' => $this->location->getRecent()[0]->updated_at->format('Y M d'),
|
2024-01-26 12:16:38 -06:00
|
|
|
'title' => "Search Results",
|
2023-08-21 12:56:26 -07:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2023-08-18 14:34:53 -07:00
|
|
|
public function about()
|
|
|
|
{
|
2024-02-19 13:30:00 -06:00
|
|
|
$sources = $this->source->getActive();
|
2023-08-18 14:34:53 -07:00
|
|
|
return view('front.about', [
|
2023-09-05 13:30:57 -07:00
|
|
|
'title' => "ABOUT",
|
|
|
|
'sources' => $sources
|
2023-08-18 14:34:53 -07:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-02-02 12:16:11 -06:00
|
|
|
public function appeals()
|
|
|
|
{
|
|
|
|
return view('front.appeals', [
|
|
|
|
'title' => "LOCATION APPEALS",
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2023-08-18 14:34:53 -07:00
|
|
|
public function location(string $uuid = "1")
|
|
|
|
{
|
2024-02-19 13:30:00 -06:00
|
|
|
$location = $this->location->getLocation($uuid);
|
|
|
|
$sources = $this->source->getActive();
|
2023-08-18 14:34:53 -07:00
|
|
|
$name = "NO LOCATION FOUND";
|
|
|
|
if ($location) {
|
|
|
|
$name = $location->name;
|
|
|
|
}
|
|
|
|
return view('front.location', [
|
2023-09-25 13:09:50 -07:00
|
|
|
'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'),
|
2023-08-17 15:14:01 -07:00
|
|
|
]);
|
2023-08-14 13:33:53 -07:00
|
|
|
}
|
2023-08-17 19:50:38 -07:00
|
|
|
|
|
|
|
public function listings(int $pageNum = 1)
|
|
|
|
{
|
2024-02-19 13:30:00 -06:00
|
|
|
$listing = $this->location->getPage($pageNum);
|
2023-08-17 19:50:38 -07:00
|
|
|
|
|
|
|
return view('front.listing', [
|
|
|
|
'title' => "Listings",
|
2024-02-19 13:30:00 -06:00
|
|
|
'sources' => count($this->source->getActive()),
|
2024-02-09 14:53:08 -06:00
|
|
|
"totalPages" => $listing[1],
|
|
|
|
"prev" => $listing[2],
|
|
|
|
"next" => $listing[3],
|
2023-08-17 19:50:38 -07:00
|
|
|
'pageNum' => $pageNum,
|
2024-02-09 14:53:08 -06:00
|
|
|
'locations' => $listing[0]
|
2023-08-17 19:50:38 -07:00
|
|
|
]);
|
|
|
|
}
|
2023-08-14 13:33:53 -07:00
|
|
|
}
|