Skip to content

Commit

Permalink
Assets is now its own module
Browse files Browse the repository at this point in the history
  • Loading branch information
spitfire305 committed Apr 25, 2024
1 parent 488ca27 commit 64fc9b7
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 3 deletions.
9 changes: 9 additions & 0 deletions app/Http/Controllers/Entity/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ class AssetController extends Controller

public function index(Campaign $campaign, Entity $entity)
{
if (!$campaign->enabled('assets')) {
return redirect()->route('entities.show', [$campaign, $entity])->with(
'error_raw',
__('campaigns.settings.errors.module-disabled', [
'fix' => link_to_route('campaign.modules', __('crud.fix-this-issue'), ['#assets']),
])
);
}

$this->authEntityView($entity);

$assets = $entity->assets;
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/Entity/AttributeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ public function __construct(AttributeService $attributeService, TemplateService
public function index(Campaign $campaign, Entity $entity)
{
if (!$campaign->enabled('entity_attributes')) {
return redirect()->route('dashboard', $campaign)->with(
return redirect()->route('entities.show', [$campaign, $entity])->with(
'error_raw',
__('campaigns.settings.errors.module-disabled', [
'fix' => link_to_route('campaign.modules', __('crud.fix-this-issue'), ['#entity_attributes']),
'fix' => link_to_route('campaign.modules', __('crud.fix-this-issue'), ['#assets']),
])
);
}

$this->authEntityView($entity);

if (!$entity->accessAttributes()) {
Expand Down
9 changes: 9 additions & 0 deletions app/Http/Controllers/Entity/InventoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ class InventoryController extends Controller

public function index(Campaign $campaign, Entity $entity)
{
if (!$campaign->enabled('inventories')) {
return redirect()->route('entities.show', [$campaign, $entity])->with(
'error_raw',
__('campaigns.settings.errors.module-disabled', [
'fix' => link_to_route('campaign.modules', __('crud.fix-this-issue'), ['#inventories']),
])
);
}

$this->authEntityView($entity);

$inventory = $entity
Expand Down
1 change: 1 addition & 0 deletions app/Models/CampaignSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CampaignSetting extends Model

protected $fillable = [
'abilities',
'assets',
'campaign_id',
'characters',
'entity_attributes',
Expand Down
2 changes: 1 addition & 1 deletion app/Models/MiscModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public function menuItems(array $items = []): array


// Each entity can have assets
if ($this->entity->hasFiles()) {
if ($campaign->enabled('assets') && $this->entity->hasFiles()) {
$items['third']['assets'] = [
'name' => 'crud.tabs.assets',
'route' => 'entities.entity_assets.index',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('campaign_settings', function (Blueprint $table) {
$table->boolean('assets')->default(true);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('campaign_settings', function (Blueprint $table) {
$table->dropColumn('assets');
});
}
};
1 change: 1 addition & 0 deletions lang/en/campaigns.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@
],
'helpers' => [
'abilities' => 'Create abilities, be it feats, spells, or powers that can be assigned to entities.',
'assets' => 'Upload files, links and aliases to individual entities.',
'bookmarks' => 'Create bookmarks to entities or filtered lists that appear in the sidebar.',
'calendars' => 'A place to define the calendars of your world.',
'characters' => 'Create and keep track of the people inhabiting the world with characters.',
Expand Down
1 change: 1 addition & 0 deletions lang/en/entities.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
return [
'abilities' => 'Abilities',
'ability' => 'Ability',
'assets' => 'Assets',
'attribute_template' => 'Attribute Template',
'attribute_templates' => 'Attribute Templates',
'bookmark' => 'Bookmark',
Expand Down
3 changes: 3 additions & 0 deletions resources/views/campaigns/modules/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
<div class="cell col-span-1 flex">
@include('campaigns.modules.box', ['icon' => 'fa-solid fa-table', 'module' => 'entity_attributes'])
</div>
<div class="cell col-span-1 flex">
@include('campaigns.modules.box', ['icon' => 'fa-solid fa-folder', 'module' => 'assets'])
</div>
</div>
</div>
@endsection
Expand Down

0 comments on commit 64fc9b7

Please sign in to comment.