Skip to content

Commit

Permalink
Merge branch 'release/2024.7.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dioscorides committed Jul 5, 2024
2 parents 64f582a + be55f33 commit 3307020
Show file tree
Hide file tree
Showing 36 changed files with 2,319 additions and 2,767 deletions.
17 changes: 17 additions & 0 deletions app/Http/Controllers/HomepageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Http\Controllers;

use App\Models\Library;

class HomepageController extends Controller
{
public function index(): \Illuminate\Contracts\View\Factory|\Illuminate\Foundation\Application|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
{
// Fetch the latest edited libraries from the database
$latest_changes = Library::orderBy('last_edited', 'desc')->take(5)->get();

// Pass the data to the view
return view('landing_page', compact('latest_changes'));
}
}
7 changes: 4 additions & 3 deletions app/Http/Controllers/LibraryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

class LibraryController extends Controller
{

private Library $library;

/**
Expand Down Expand Up @@ -42,8 +41,9 @@ private function getLibrariesInRandomOrder()
public function index(): View|Factory|JsonResponse|Application
{
$libraries = $this->getLibrariesInRandomOrder();
$latest_changes = $this->library->orderBy('last_edited', 'desc')->take(5)->get();

return view('public/data', compact('libraries'));
return view('public/data', compact('libraries', 'latest_changes'));
}

/**
Expand All @@ -52,8 +52,9 @@ public function index(): View|Factory|JsonResponse|Application
public function map(): View|Factory|Application
{
$libraries = $this->getLibrariesInRandomOrder();
$latest_changes = $this->library->orderBy('last_edited', 'desc')->take(5)->get();

return view('public/map', compact('libraries'));
return view('public/map', compact('libraries', 'latest_changes'));
}

/**
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/RandomInstitutionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ class RandomInstitutionController extends Controller
*/
public function __invoke(Request $request): RedirectResponse
{
//NOTE fetch a random library from the database
$get_random_library = Library::inRandomOrder()
//NOTE fetch a random library from the database that has not been disabled
$get_random_library = Library::where('is_disabled', false)
->inRandomOrder()
->limit(1)
->get();

Expand Down
28 changes: 28 additions & 0 deletions app/View/Components/Latest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\View\Components;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;

class Latest extends Component
{
public mixed $latestChanges;

/**
* Create a new component instance.
*/
public function __construct($latestChanges)
{
$this->latestChanges = $latestChanges;
}

/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.latest', ['latest_changes' => $this->latestChanges]);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"barryvdh/laravel-ide-helper": "^2.12",
"fakerphp/faker": "^1.9.1",
"laracasts/cypress": "^3.0",
"laravel/pint": "^1.14",
"laravel/pint": "^1.16",
"laravel/sail": "^1.0.1",
"laravel/ui": "^4.2",
"mockery/mockery": "^1.4.4",
Expand Down
Loading

0 comments on commit 3307020

Please sign in to comment.