Skip to content

Commit

Permalink
Bunch of small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
spitfire305 committed Apr 18, 2024
1 parent ef364d7 commit fb93442
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 56 deletions.
2 changes: 2 additions & 0 deletions app/Http/Requests/StoreCreature.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function rules()
'image' => 'mimes:jpeg,png,jpg,gif,webp|max:' . Limit::upload(),
'image_url' => 'nullable|url|active_url',
'template_id' => 'nullable',
'locations' => 'array',
'locations.*' => 'distinct|exists:locations,id',
];

/** @var Creature $self */
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Requests/StoreOrganisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function rules()
'organisation_id' => 'nullable|exists:organisations,id',
'image_url' => 'nullable|url|active_url',
'template_id' => 'nullable',
'locations' => 'array',
'locations.*' => 'distinct|exists:locations,id',
];

/** @var Organisation $self */
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Requests/StoreRace.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function rules()
'image' => 'mimes:jpeg,png,jpg,gif,webp|max:' . Limit::upload(),
'image_url' => 'nullable|url|active_url',
'template_id' => 'nullable',
'locations' => 'array',
'locations.*' => 'distinct|exists:locations,id',
];

/** @var Race $self */
Expand Down
7 changes: 1 addition & 6 deletions app/Models/Organisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @property Collection|OrganisationMember[] $members
* @property Collection|Organisation[] $descendants
* @property Collection|Organisation[] $organisations
* * @property Collection|Location[] $locations
* @property Collection|Location[] $locations
* @property bool $is_defunct
*/
class Organisation extends MiscModel
Expand Down Expand Up @@ -66,7 +66,6 @@ class Organisation extends MiscModel
* Fields that can be sorted on
*/
protected array $sortableColumns = [
'location.name',
'is_defunct',
];

Expand All @@ -80,7 +79,6 @@ class Organisation extends MiscModel

protected array $exportFields = [
'base',
'location_id',
'is_defunct',
];

Expand All @@ -91,7 +89,6 @@ class Organisation extends MiscModel
* @var string[]
*/
public array $nullableForeignKeys = [
'location_id',
'organisation_id'
];

Expand All @@ -106,8 +103,6 @@ public function scopePreparedWith(Builder $query): Builder
->with([
'entity',
'entity.image',
'location',
'location.entity',
'locations' => function ($sub) {
$sub->select('id', 'name');
},
Expand Down
1 change: 1 addition & 0 deletions app/Services/Campaign/Import/Mappers/EntityMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ protected function foreign(string $model, string $field): self

protected function pivot(string $relation, string $model, string $field): self
{
//Check if import has old location_id and migrate it to new locations pivot table system, currently only happens with organisations
if ($relation == 'pivotLocations' && isset($this->data['location_id']) && !in_array(['location_id' => $this->data['location_id']], $this->data[$relation])) {
$this->data[$relation][] = ['location_id' => $this->data['location_id']];
}
Expand Down
6 changes: 3 additions & 3 deletions app/Services/Entity/ConnectionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ protected function initRace()
{
$this
->loadChildRaces()
->loadRaceLocations()
->loadLocations()
;
}

protected function initOrganisation()
{
$this
->loadMapMarkers()
->loadRaceLocations()
->loadLocations()
->loadTimelines()
->loadQuests()
->loadAuthoredJournals()
Expand Down Expand Up @@ -319,7 +319,7 @@ protected function loadChildRaces(): self
return $this;
}

protected function loadRaceLocations(): self
protected function loadLocations(): self
{
/** @var Location $parent */
$parent = $this->entity->child;
Expand Down
15 changes: 15 additions & 0 deletions resources/views/entities/components/profile/_locations.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@if ($campaign->enabled('locations') && !$model->locations->isEmpty())
<div class="element profile-location">
<div class="title text-uppercase text-xs">
{!! \App\Facades\Module::plural(config('entities.ids.location'), __('entities.locations')) !!}
</div>
@php $existingLocations = []; @endphp
@foreach ($model->locations()->with('entity')->get() as $location)
@if(!empty($existingLocations[$location->id]))
@continue
@endif
@php $existingLocations[$location->id] = true; @endphp
{!! $location->tooltipedLink() !!}
@endforeach
</div>
@endif
17 changes: 1 addition & 16 deletions resources/views/entities/components/profile/creatures.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,6 @@
@endif

<x-sidebar.profile>
@if ($campaign->enabled('locations') && !$model->locations->isEmpty())
<div class="element profile-location">
<div class="title text-uppercase text-xs">
{!! \App\Facades\Module::plural(config('entities.ids.location'), __('entities.locations')) !!}
</div>
@php $existingLocations = []; @endphp
@foreach ($model->locations as $location)
@if(!empty($existingLocations[$location->id]))
@continue
@endif
@php $existingLocations[$location->id] = true; @endphp
{!! $location->tooltipedLink() !!}
@endforeach
</div>
@endif

@include('entities.components.profile._locations')
@include('entities.components.profile._type')
</x-sidebar.profile>
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,7 @@
@endif

<x-sidebar.profile>
@if ($campaign->enabled('locations') && !$model->locations->isEmpty())
<div class="element profile-location">
<div class="title text-uppercase text-xs">
{!! \App\Facades\Module::plural(config('entities.ids.location'), __('entities.locations')) !!}
</div>
@php $existingRaces = []; @endphp
@foreach ($model->locations()->with('entity')->get() as $location)
@if(!empty($existingLocations[$location->id]))
@continue
@endif
@php $existingLocations[$location->id] = true; @endphp
{!! $location->tooltipedLink() !!}
@endforeach
</div>
@endif
@include('entities.components.profile._locations')
@include('entities.components.profile._type')
@include('entities.components.profile._events')
</x-sidebar.profile>
17 changes: 1 addition & 16 deletions resources/views/entities/components/profile/races.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,6 @@
@endif

<x-sidebar.profile>
@if ($campaign->enabled('locations') && !$model->locations->isEmpty())
<div class="element profile-location">
<div class="title text-uppercase text-xs">
{!! \App\Facades\Module::plural(config('entities.ids.location'), __('entities.locations')) !!}
</div>
@php $existingRaces = []; @endphp
@foreach ($model->locations()->with('entity')->get() as $location)
@if(!empty($existingLocations[$location->id]))
@continue
@endif
@php $existingLocations[$location->id] = true; @endphp
{!! $location->tooltipedLink() !!}
@endforeach
</div>
@endif

@include('entities.components.profile._locations')
@include('entities.components.profile._type')
</x-sidebar.profile>

0 comments on commit fb93442

Please sign in to comment.