Skip to content

Commit

Permalink
Drop Livewire for home page
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstauffer committed Jul 12, 2024
1 parent 28850fa commit e4f2131
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 52 deletions.
50 changes: 50 additions & 0 deletions app/Http/Controllers/OrganizationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace App\Http\Controllers;

use App\Models\Organization;
use App\Models\Technology;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Cache;

class OrganizationController extends Controller
{
public function index()
{
return view('organizations.index', [
'organizations' => $this->organizations(),
'technologies' => $this->technologies(),
'filterTechnology' => null,
]);
}

public function indexByTechnology(string $filterTechnology)
{
return view('organizations.index', [
'organizations' => $this->organizations($filterTechnology),
'technologies' => $this->technologies(),
'filterTechnology' => $filterTechnology,
]);
}

private function organizations(?string $filterTechnology = null)
{
return Cache::remember('orgs-list-filter[' . $filterTechnology . ']', 3600, function () use ($filterTechnology) {
return Organization::when(! is_null($filterTechnology), function (Builder $query) use ($filterTechnology) {
$query->whereHas('technologies', function (Builder $query) use ($filterTechnology) {
$query->where('slug', $filterTechnology);
});
})->with('sites') // @todo: Do a subquery for just the first site aaron francis style?
->orderBy('featured_at', 'desc')
->orderBy('created_at', 'desc')
->get();
});
}

private function technologies()
{
return Cache::remember('active-organizations', 3600, function () {
return Technology::whereHas('organizations')->orderBy('name')->get();
});
}
}
44 changes: 0 additions & 44 deletions app/Livewire/OrgsList.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class="{{ $filterTechnology == null ? 'border-tighten-yellow text-black hover:bo
All
<span class="hidden md:inline-block">Technologies</span>
</a>
@foreach ($this->technologies as $tech)
@foreach ($technologies as $tech)
<a
href="{{ route('technologies.show', $tech->slug) }}"
class="{{ $filterTechnology == $tech->slug ? 'border-tighten-yellow hover:border-tighten-yellow text-black ' : 'text-bgrey-400 hover:text-gray-600 hover:border-gray-400 ' }} border-b-2 border-black/10 px-3 py-1 transition duration-300 active:border-tighten-yellow active:text-tighten-yellow"
Expand All @@ -20,7 +20,7 @@ class="{{ $filterTechnology == $tech->slug ? 'border-tighten-yellow hover:border
</div>

<div class="grid gap-6 sm:grid-cols-2 lg:grid-cols-3 lg:gap-8">
@foreach ($this->organizations as $org)
@foreach ($organizations as $org)
<x-org-in-list :org="$org"></x-org-in-list>
@endforeach
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<x-public-layout>
<livewire:orgs-list />
<x-orgs-list :organizations="$organizations" :technologies="$technologies" :filterTechnology="$filterTechnology"></x-orgs-list>

<div class="mt-24 text-center text-bgrey-500 md:text-2xl" id="about">
<h2 class="mb-6 text-2xl font-bold uppercase text-black md:text-4xl">About</h2>
Expand Down
3 changes: 0 additions & 3 deletions resources/views/technologies/show.blade.php

This file was deleted.

5 changes: 3 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

use App\Http\Controllers\OrganizationController;
use App\Http\Controllers\SuggestOrganizationController;
use App\Models\Organization;
use App\Models\Technology;
use Illuminate\Support\Facades\Route;

Route::view('/', 'home')->name('home');
Route::get('/', [OrganizationController::class, 'index'])->name('home');
Route::get('orgs/{organization}', function (Organization $organization) {
return view('organizations.show', ['organization' => $organization]);
})->name('organizations.show');
Expand All @@ -16,7 +17,7 @@

require __DIR__ . '/auth.php';

Route::view('{technology}', 'technologies.show')->name('technologies.show');
Route::get('{technology}', [OrganizationController::class, 'indexbyTechnology'])->name('technologies.show');

/*
Expand Down

0 comments on commit e4f2131

Please sign in to comment.