2023-08-14 22:33:53 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2023-08-21 21:56:26 +02:00
|
|
|
use Illuminate\Http\Request;
|
2024-02-21 23:47:05 +01:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2024-02-09 21:53:08 +01:00
|
|
|
use App\Repositories\LocationRepository;
|
2024-02-19 20:30:00 +01:00
|
|
|
use App\Repositories\SourceRepository;
|
2024-02-20 19:57:33 +01:00
|
|
|
use App\Services\PaginationService;
|
2023-08-14 22:33:53 +02:00
|
|
|
|
|
|
|
class FrontIndexController extends Controller
|
|
|
|
{
|
2024-02-19 20:30:00 +01:00
|
|
|
protected $location;
|
|
|
|
protected $source;
|
2024-02-20 19:57:33 +01:00
|
|
|
protected $pagination;
|
2023-08-18 04:50:38 +02:00
|
|
|
|
2024-02-19 20:30:00 +01:00
|
|
|
public function __construct(
|
|
|
|
LocationRepository $locationRepository,
|
2024-02-20 19:57:33 +01:00
|
|
|
SourceRepository $sourceRepository,
|
|
|
|
PaginationService $paginationService
|
2024-02-19 20:30:00 +01:00
|
|
|
) {
|
2024-02-20 19:57:33 +01:00
|
|
|
$this->location = $locationRepository;
|
|
|
|
$this->source = $sourceRepository;
|
|
|
|
$this->pagination = $paginationService;
|
2024-01-23 19:04:52 +01:00
|
|
|
}
|
2024-01-22 20:45:11 +01:00
|
|
|
|
2024-01-23 19:04:52 +01:00
|
|
|
public function start()
|
|
|
|
{
|
2023-08-18 00:14:01 +02:00
|
|
|
return view('front.index', [
|
2024-02-19 20:30:00 +01: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 19:16:38 +01:00
|
|
|
'title' => "The Bad Space"
|
2023-08-18 23:34:53 +02:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2023-08-21 21:56:26 +02:00
|
|
|
public function indexSearch(Request $request)
|
|
|
|
{
|
|
|
|
return view('front.index', [
|
2024-02-19 20:30:00 +01:00
|
|
|
'count' => count($this->location->getActiveLocations()),
|
|
|
|
'sources' => count($this->source->getActive()),
|
|
|
|
'recent' => $this->location->getRecent(),
|
|
|
|
'results' => $this->location->search($request),
|
2024-02-09 21:53:08 +01:00
|
|
|
'terms' => $request->index_search,
|
2024-02-19 20:30:00 +01:00
|
|
|
'latest_date' => $this->location->getRecent()[0]->updated_at->format('Y M d'),
|
2024-01-26 19:16:38 +01:00
|
|
|
'title' => "Search Results",
|
2023-08-21 21:56:26 +02:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2023-08-18 23:34:53 +02:00
|
|
|
public function about()
|
|
|
|
{
|
2024-02-19 20:30:00 +01:00
|
|
|
$sources = $this->source->getActive();
|
2023-08-18 23:34:53 +02:00
|
|
|
return view('front.about', [
|
2023-09-05 22:30:57 +02:00
|
|
|
'title' => "ABOUT",
|
|
|
|
'sources' => $sources
|
2023-08-18 23:34:53 +02:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-02-02 19:16:11 +01:00
|
|
|
public function appeals()
|
|
|
|
{
|
|
|
|
return view('front.appeals', [
|
|
|
|
'title' => "LOCATION APPEALS",
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2023-08-18 23:34:53 +02:00
|
|
|
public function location(string $uuid = "1")
|
|
|
|
{
|
2024-02-19 20:30:00 +01:00
|
|
|
$location = $this->location->getLocation($uuid);
|
|
|
|
$sources = $this->source->getActive();
|
2023-08-18 23:34:53 +02:00
|
|
|
$name = "NO LOCATION FOUND";
|
2024-02-21 23:47:05 +01:00
|
|
|
$member = Auth::user();
|
|
|
|
$edit = false;
|
2023-08-18 23:34:53 +02:00
|
|
|
if ($location) {
|
|
|
|
$name = $location->name;
|
|
|
|
}
|
2024-02-21 23:47:05 +01:00
|
|
|
|
|
|
|
if (isset($member->role)) {
|
|
|
|
($member->role == 1 || $member->role == 2) ? $edit = true : $edit = false;
|
|
|
|
}
|
|
|
|
|
2024-09-13 23:12:43 +02:00
|
|
|
$links = explode(',', $location->archive_links);
|
2023-08-18 23:34:53 +02:00
|
|
|
return view('front.location', [
|
2023-09-25 22:09:50 +02:00
|
|
|
'title' => str_replace(".", " ", $name),
|
|
|
|
'location' => $location,
|
|
|
|
'actions' => $location->block_count + $location->silence_count,
|
|
|
|
'sources_count' => count($sources),
|
|
|
|
'images' => json_decode($location->images),
|
2024-09-13 23:12:43 +02:00
|
|
|
'links' => $links,
|
2023-09-25 22:09:50 +02:00
|
|
|
'updated' => $location->updated_at->format('Y M d'),
|
2024-02-21 23:47:05 +01:00
|
|
|
'edit' => $edit
|
2023-08-18 00:14:01 +02:00
|
|
|
]);
|
2023-08-14 22:33:53 +02:00
|
|
|
}
|
2023-08-18 04:50:38 +02:00
|
|
|
|
|
|
|
public function listings(int $pageNum = 1)
|
|
|
|
{
|
2024-02-20 19:57:33 +01:00
|
|
|
$page = $this->pagination->getPage($pageNum);
|
2023-08-18 04:50:38 +02:00
|
|
|
|
|
|
|
return view('front.listing', [
|
|
|
|
'title' => "Listings",
|
2024-02-19 20:30:00 +01:00
|
|
|
'sources' => count($this->source->getActive()),
|
2024-02-20 19:57:33 +01:00
|
|
|
"totalPages" => $page['pageCount'],
|
|
|
|
"prev" => $page['prev'],
|
|
|
|
"next" => $page['next'],
|
2023-08-18 04:50:38 +02:00
|
|
|
'pageNum' => $pageNum,
|
2024-02-20 19:57:33 +01:00
|
|
|
'locations' => $page['locations']
|
2023-08-18 04:50:38 +02:00
|
|
|
]);
|
|
|
|
}
|
2023-08-14 22:33:53 +02:00
|
|
|
}
|