mirror of
https://koodu.h-i.works/projects/thebadspace
synced 2025-05-06 14:41:02 -05:00
Migrations were pretty much useless for database set up, so that needed some attention to make setting up the project easier. Now, all necessary tables can be created by running the `artisan migrate` command assuming one has the database parameters set in the .env file also added full text search capabilites through the database set up, which the model itself can use to find locations, so the search has been updated in the appropriate locations as well. still need to add initial account set up and a form for adding sources through the UI, but this was a big step towards letting anyone set up their own version of tbs
118 lines
3.8 KiB
PHP
118 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
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()
|
|
{
|
|
//for fresh installs that dont have any source data yet
|
|
$latest_update = 'Never Run';
|
|
if(count($this->location->getRecent()) != 0)
|
|
{
|
|
$latest_update = $this->location->getRecent()[0]->updated_at->format('Y M d');
|
|
}
|
|
return view('front.index', [
|
|
'count' => count($this->location->getActiveLocations()),
|
|
'sources' => count($this->source->getActive()),
|
|
'recent' => $this->location->getRecent(),
|
|
'latest_date' => $latest_update,
|
|
'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";
|
|
$member = Auth::user();
|
|
$edit = false;
|
|
if ($location) {
|
|
$name = $location->name;
|
|
}
|
|
|
|
if (isset($member->role)) {
|
|
($member->role == 0 || $member->role == 1) ? $edit = true : $edit = false;
|
|
}
|
|
|
|
$links = explode(',', $location->archive_links);
|
|
$comments = explode('+', $location->public_comments);
|
|
return view('front.location', [
|
|
'title' => str_replace(".", " ", $name),
|
|
'location' => $location,
|
|
'comments' => $comments,
|
|
'actions' => $location->block_count + $location->silence_count,
|
|
'sources_count' => count($sources),
|
|
'images' => json_decode($location->images),
|
|
'links' => $links,
|
|
'updated' => $location->updated_at->format('Y M d'),
|
|
'edit' => $edit
|
|
]);
|
|
}
|
|
|
|
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']
|
|
]);
|
|
}
|
|
}
|