Migration complete

This commit is contained in:
2026-06-23 19:24:38 +02:00
parent 279160c1cb
commit 64b26ef059
126 changed files with 8121 additions and 221 deletions

View File

@@ -128,7 +128,7 @@ class Database extends Component
* Categories mode and/or
* @var string
*/
#[Url(except:['or'])]
#[Url(except:'or')]
public string $categoriesMode = 'or';
/**
@@ -142,7 +142,7 @@ class Database extends Component
* Systems mode and/or
* @var string
*/
#[Url(except:['or'])]
#[Url(except:'or')]
public string $systemsMode = 'or';
/**
@@ -152,6 +152,9 @@ class Database extends Component
#[Url(except:[])]
public array $levels = [];
#[Url(except:null)]
public ?int $userId = null;
/**
* Sort by field.
* @var string
@@ -185,7 +188,6 @@ class Database extends Component
'utilities' => 'Utilities',
'documents' => 'Documents',
'lua-scripts' => 'Lua Scripts',
'tutorials' => 'Tutorials',
];
public const int PAGINATION = 30;
@@ -207,12 +209,14 @@ class Database extends Component
public function updatedSystems(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function updatedSystemsMode(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function updatedLevels(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function updatedUserId(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function clearFilters(): void
{
$this->reset([
'search', 'types', 'platforms', 'genres', 'statuses', 'authors', 'authorsMode', 'languages', 'languagesMode', 'modifications', 'modificationsMode', 'categories', 'categoriesMode', 'systems', 'systemsMode', 'levels'
'search', 'types', 'platforms', 'genres', 'statuses', 'authors', 'authorsMode', 'languages', 'languagesMode', 'modifications', 'modificationsMode', 'categories', 'categoriesMode', 'systems', 'systemsMode', 'levels', 'userId'
]);
$this->dispatch('filters-updated');
$this->resetPage();
}
@@ -320,18 +324,59 @@ class Database extends Component
}
}
if( $this->userId ){
$query->where('user_id', $this->userId);
}
return $query->orderBy($this->sortBy, $this->sortDir);
}
private function searchFilter( string $modelClass, string $search )
{
$this->dispatch('filters-updated');
if( mb_strlen( $search ) < 3 ) {
return collect();
}
return $modelClass::where('name', 'like', "%{$search}%")
->orderBy('name')
->limit(50)
->get();
}
private function searchGameFilter()
{
$search = $this->gameSearch;
$this->dispatch('filters-updated');
if( mb_strlen( $search ) < 3 ) {
return collect();
}
$collect = Game::where('name', 'like', "%{$search}%")
->orderBy('name')
->limit(50)
->get();
return $collect->map(function($item){
$item->name = $item->name . ' (' . ($item->platform?->short_name ?? $item->platform->name) . ')';
return $item;
} );
}
public function render()
{
return view('livewire.database', [
'entries' => $this->buildQuery()->paginate(self::PAGINATION),
'allGames' => Game::orderBy('name')->get(),
'allGames' => $this->searchGameFilter(),
'allPlatforms' => Platform::orderBy('name')->get(),
'allGenres' => Genre::orderBy('name')->get(),
'allStatuses' => Status::orderBy('name')->get(),
'allAuthors' => Author::orderBy('name')->get(),
'allAuthors' => $this->searchFilter(Author::class, $this->authorSearch),
'allLanguages' => Language::orderBy('name')->get(),
'allModifications' => Modification::orderBy('name')->get(),
'allCategories' => Category::orderBy('name')->get(),

View File

@@ -0,0 +1,81 @@
<?php
namespace App\Livewire;
use App\Helpers\HashesHelpers;
use App\Models\EntryHash;
use App\Models\Game;
use App\Models\Genre;
use App\Models\Platform;
use Illuminate\View\View;
use Livewire\Component;
/**
* @phpstan-import-type HashObject from \App\Types\SubmissionTypes
*/
class HashesChecker extends Component
{
/**
* Current hash.
* @var null|HashObject $hash
*/
public ?array $hash = null;
/**
* Add a hash.
*
* @param string $filename
* @param string $crc32
* @param string $sha1
* @param string|null $verified
*
* @return void
*/
public function addHash(string $filename, string $crc32, string $sha1, ?string $verified = null): void
{
if( $verified !== null && $verified !== "No" )
$this->hash = [
'filename' => $filename,
'hash_crc32' => $crc32,
'hash_sha1' => $sha1,
'verified' => $verified
];
else if( ( $hash = HashesHelpers::findHashes( $sha1 ) ) !== null )
$this->hash = [
'filename' => $hash->filename,
'hash_crc32' => $hash->crc32,
'hash_sha1' => $hash->sha1,
'verified' => HashesHelpers::getReferenceName( $hash->dat_reference_id )
];
else
$this->hash = [
'filename' => $filename,
'hash_crc32' => $crc32,
'hash_sha1' => $sha1,
'verified' => "No"
];
}
/**
* Remove the hash.
*
* @return void
*/
public function removeHash(): void
{
$this->hash = null;
$this->dispatch('refresh');
}
public function render(): View
{
$entries = collect();
if( $this->hash !== null ){
$entries = EntryHash::where('hash_sha1', $this->hash['hash_sha1'] )->get()->pluck('entry')->filter();
}
return view('livewire.hashes-checker', compact('entries'));
}
}

92
app/Livewire/Reviews.php Normal file
View File

@@ -0,0 +1,92 @@
<?php
namespace App\Livewire;
use App\Models\EntryReview;
use Livewire\Attributes\Url;
use Livewire\Component;
use Livewire\WithPagination;
class Reviews extends Component
{
use WithPagination;
#[Url(except:null)]
public ?int $entryId = null;
#[Url(except:null)]
public ?int $rating = null;
/**
* Sort by field.
* @var string
*/
#[Url(as: 'sort',except: 'created_at')]
public string $sortBy = 'created_at';
/**
* asc/desc
* @var string
*/
#[Url(as: 'dir',except: 'desc')]
public string $sortDir = 'desc';
/**
* Translation of sort options key.
*/
public const array SORT_OPTIONS = [
'created_at' => 'Date added',
'rating' => 'Rating',
'title' => 'Title'
];
public const int PAGINATION = 30;
public function updatedEntryId(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function updatedRating(): void { $this->resetPage(); $this->dispatch('filters-updated'); }
public function clearFilters(): void
{
$this->reset([
'entryId', 'rating'
]);
$this->dispatch('filters-updated');
$this->resetPage();
}
public function setSort(string $field): void
{
if( $this->sortBy === $field ) {
$this->sortDir = $this->sortDir === 'asc' ? 'desc' : 'asc';
} else {
$this->sortBy = $field;
$this->sortDir = 'asc';
}
$this->resetPage();
$this->dispatch('filters-updated');
}
private function buildQuery()
{
$query = EntryReview::query()->with([
'entry'
]);
if( $this->entryId ) {
$query->where('entry_id', $this->entryId);
}
if( $this->rating ){
$query->where('rating', $this->rating);
}
return $query->orderBy($this->sortBy, $this->sortDir);
}
public function render()
{
return view('livewire.reviews', [
'reviews' => $this->buildQuery()->paginate(self::PAGINATION),
]);
}
}