mirror of
https://koodu.h-i.works/projects/thebadspace
synced 2025-06-25 16:04:37 -05:00
Added Source Repository Class
Created a class to handle source data and methodology, and to offload actions from service classes to make them easier to manage
This commit is contained in:
@ -3,25 +3,29 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Source;
|
||||
use App\Repositories\LocationRepository;
|
||||
use App\Repositories\SourceRepository;
|
||||
|
||||
class FrontIndexController extends Controller
|
||||
{
|
||||
protected $locationRepository;
|
||||
protected $location;
|
||||
protected $source;
|
||||
|
||||
public function __construct(LocationRepository $locationRepository)
|
||||
{
|
||||
$this->locationRepository = $locationRepository;
|
||||
public function __construct(
|
||||
LocationRepository $locationRepository,
|
||||
SourceRepository $sourceRepository
|
||||
) {
|
||||
$this->location = $locationRepository;
|
||||
$this->source = $sourceRepository;
|
||||
}
|
||||
|
||||
public function start()
|
||||
{
|
||||
return view('front.index', [
|
||||
'count' => count($this->locationRepository->getActiveLocations()),
|
||||
'sources' => count(Source::where("active", true)->get()),
|
||||
'recent' => $this->locationRepository->getRecent(),
|
||||
'latest_date' => $this->locationRepository->getRecent()[0]->updated_at->format('Y M d'),
|
||||
'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"
|
||||
]);
|
||||
}
|
||||
@ -29,19 +33,19 @@ class FrontIndexController extends Controller
|
||||
public function indexSearch(Request $request)
|
||||
{
|
||||
return view('front.index', [
|
||||
'count' => count($this->locationRepository->getActiveLocations()),
|
||||
'sources' => count(Source::where("active", true)->get()),
|
||||
'recent' => $this->locationRepository->getRecent(),
|
||||
'results' => $this->locationRepository->search($request),
|
||||
'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->locationRepository->getRecent()[0]->updated_at->format('Y M d'),
|
||||
'latest_date' => $this->location->getRecent()[0]->updated_at->format('Y M d'),
|
||||
'title' => "Search Results",
|
||||
]);
|
||||
}
|
||||
|
||||
public function about()
|
||||
{
|
||||
$sources = Source::where("active", true)->get();
|
||||
$sources = $this->source->getActive();
|
||||
return view('front.about', [
|
||||
'title' => "ABOUT",
|
||||
'sources' => $sources
|
||||
@ -57,8 +61,8 @@ class FrontIndexController extends Controller
|
||||
|
||||
public function location(string $uuid = "1")
|
||||
{
|
||||
$location = $this->locationRepository->getLocation($uuid);
|
||||
$sources = Source::where("active", true)->get();
|
||||
$location = $this->location->getLocation($uuid);
|
||||
$sources = $this->source->getActive();
|
||||
$name = "NO LOCATION FOUND";
|
||||
if ($location) {
|
||||
$name = $location->name;
|
||||
@ -75,11 +79,11 @@ class FrontIndexController extends Controller
|
||||
|
||||
public function listings(int $pageNum = 1)
|
||||
{
|
||||
$listing = $this->locationRepository->getPage($pageNum);
|
||||
$listing = $this->location->getPage($pageNum);
|
||||
|
||||
return view('front.listing', [
|
||||
'title' => "Listings",
|
||||
'sources' => count(Source::where("active", true)->get()),
|
||||
'sources' => count($this->source->getActive()),
|
||||
"totalPages" => $listing[1],
|
||||
"prev" => $listing[2],
|
||||
"next" => $listing[3],
|
||||
|
Reference in New Issue
Block a user