Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilestis committed Jan 16, 2024
1 parent 35c1b8f commit 6a53ffd
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/Http/Controllers/Search/GameSystemSearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function index(Campaign $campaign): JsonResponse
/** @var GameSystem[] $systems */
$systems = GameSystem::where('name', 'like', '%' . request()->get('q') . '%')
->withCount('campaignSystem')->orderBy('campaign_system_count', 'desc')
->orderBy('name', 'asc')
->limit(20)
->get();

Expand All @@ -33,7 +34,7 @@ public function index(Campaign $campaign): JsonResponse
}

return response()->json(
$formatted
$formatted ?? []
);
}
}
4 changes: 4 additions & 0 deletions app/Models/GameSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

use Illuminate\Database\Eloquent\Model;

/**
* @property int $id
* @property string $name
*/
class GameSystem extends Model
{
public function campaignSystem()
Expand Down
5 changes: 4 additions & 1 deletion app/Models/Scopes/CampaignScopes.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public function scopeFront(Builder $query, int $sort = null): Builder
}
$defaultSort = $sort == 1 ? 'follower' : 'visible_entity_count';
$query
->with('systems')
->where('is_hidden', 0)
->orderBy($defaultSort, 'desc')
->orderBy('name');
Expand Down Expand Up @@ -168,7 +169,9 @@ public function scopeFilterPublic(Builder $query, array $options): Builder
->select('campaigns.*')
->leftJoin('campaign_system as cs', function ($join) {
$join->on('cs.campaign_id', '=', 'campaigns.id');
})->whereIn('cs.system_id', $system)->distinct();
})
->whereIn('cs.system_id', $system)
->distinct();
}
$boosted = Arr::get($options, 'is_boosted');
if ($boosted === "1") {
Expand Down
1 change: 1 addition & 0 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function run()
$this->call(EntityTypesTableSeeder::class);
$this->call(PresetTypeTableSeeder::class);
//$this->call(RpgSystemsTableSeeder::class);
$this->call(GameSystemSeeder::class);
$this->call(ThemesTableSeeder::class);
$this->call(RolesTableSeeder::class);
$this->call(VisibilitiesTableSeeder::class);
Expand Down
85 changes: 85 additions & 0 deletions database/seeders/GameSystemSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

namespace Database\Seeders;

use App\Models\GameSystem;
use App\Models\Genre;
use Illuminate\Database\Seeder;

class GameSystemSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$genres = [
'D&D', 'D&D 5e', 'D&D 3.5', 'D&D 3', 'D&D 4', 'AD&D 2'.
'Pathfinder', 'Pathfinder 2e',
'Savage Worlds',
'Chronicles of Darkness',
'GURPS',
'Fate',
'Dungeon World',
'DSA',
'Powered by the Apocalypse',
'Ordem Paranormal',
'Starfinder',
'Genesys',
'Shadowrun',
'Starts Without Numbers',
'Call of Cthulu',
'World of Darkness',
'Cyberpunk Red',
'Ironsworn',
'Blades in the Dark',
'Homebrew',
'Other',
'Forbidden Lands',
'Traveller',
'Cypther System',
'Vampire the Masquerade',
'Lancer',
'Tormenta 20',
'Fabula Ultima',
'Cyberpunk 2020',
'Symbaroum',
'Warhammer',
'13th Age',
'Monster of the Week',
'Mythras',
'Numenera',
'Cortex Prime',
'Legend of the Five Rings',
'7th Sea',
'Fantasy AGE',
'Knight',
'Star Wars',
'Tales from the Loop',
'The One Ring',
'Year Zero Engine',
'Exalted',
'Mörk Borg',
'Mutant Year Zero',
'None',
'Pendragon',
'Witcher',
'OSR',
'Zweihander',
'Delta Green',
'Earthdawn',
'Masks',
];
foreach ($genres as $name) {
$genre = GameSystem::firstOrNew([
'name' => $name,
]);
if ($genre->exists) {
continue;
}
$genre->fill([
'name' => $name,
])->save();
}
}
}

0 comments on commit 6a53ffd

Please sign in to comment.