Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"require": {
"php": "8.3.*|8.4.*",
"ext-dom": "*",
"ext-intl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-intl": "*",
"blade-ui-kit/blade-icons": "^1.6",
"code16/laravel-content-renderer": "^1.1",
"inertiajs/inertia-laravel": "^2.0",
Expand Down
16 changes: 1 addition & 15 deletions demo/app/Providers/DemoSharpServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
use App\Sharp\AppSearchEngine;
use App\Sharp\Demo2faNotificationHandler;
use App\Sharp\DummyGlobalFilter;
use App\Sharp\Entities\AuthorEntity;
use App\Sharp\Entities\CategoryEntity;
use App\Sharp\Entities\DemoDashboardEntity;
use App\Sharp\Entities\PostBlockEntity;
use App\Sharp\Entities\PostEntity;
use App\Sharp\Entities\ProfileEntity;
use App\Sharp\Entities\TestEntity;
use App\Sharp\SharpMenu;
use Code16\Sharp\Config\SharpConfigBuilder;
use Code16\Sharp\SharpAppServiceProvider;
Expand All @@ -24,19 +17,12 @@ protected function configureSharp(SharpConfigBuilder $config): void
{
$config
->setName('Demo project')
->addEntity('posts', PostEntity::class)
->addEntity('blocks', PostBlockEntity::class)
->addEntity('categories', CategoryEntity::class)
->addEntity('authors', AuthorEntity::class)
->addEntity('profile', ProfileEntity::class)
->addEntity('dashboard', DemoDashboardEntity::class)
->addEntity('test', TestEntity::class)
->autodiscoverEntities()
->addGlobalFilter(DummyGlobalFilter::class)
->configureUploadsThumbnailCreation(uploadModelClass: Media::class)
->setSharpMenu(SharpMenu::class)
->setThemeColor('#004c9b')
->setThemeLogo(logoUrl: '/img/sharp/logo.svg', logoHeight: '1rem', faviconUrl: '/img/sharp/favicon-32x32.png')
// ->redirectLoginToUrl('/my-login')
->enableImpersonation()
->enableForgottenPassword()
->setAuthCustomGuard('web')
Expand Down
5 changes: 3 additions & 2 deletions demo/app/Sharp/Categories/CategoryShow.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Sharp\Categories;

use App\Models\Category;
use App\Sharp\Entities\PostEntity;
use App\Sharp\Utils\Filters\CategoryFilter;
use Code16\Sharp\Show\Fields\SharpShowEntityListField;
use Code16\Sharp\Show\Fields\SharpShowTextField;
Expand Down Expand Up @@ -36,7 +37,7 @@ protected function buildShowFields(FieldsContainer $showFields): void
->setLabel('Description')
)
->addField(
SharpShowEntityListField::make('posts')
SharpShowEntityListField::make(PostEntity::class)
->setLabel('Related posts')
->showCreateButton(false)
->showCount()
Expand All @@ -54,7 +55,7 @@ protected function buildShowLayout(ShowLayout $showLayout): void
->withField('description');
});
})
->addEntityListSection('posts');
->addEntityListSection(PostEntity::class);
}

public function delete($id): void
Expand Down
1 change: 1 addition & 0 deletions demo/app/Sharp/Entities/DemoDashboardEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@

class DemoDashboardEntity extends SharpDashboardEntity
{
public static string $entityKey = 'dashboard';
protected ?string $view = DemoDashboard::class;
}
3 changes: 2 additions & 1 deletion demo/app/Sharp/Posts/Blocks/AbstractPostBlockForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Sharp\Posts\Blocks;

use App\Models\PostBlock;
use App\Sharp\Entities\PostEntity;
use Code16\Sharp\Form\Eloquent\WithSharpFormEloquentUpdater;
use Code16\Sharp\Form\Fields\SharpFormField;
use Code16\Sharp\Form\Fields\SharpFormHtmlField;
Expand Down Expand Up @@ -87,7 +88,7 @@ public function update($id, array $data)
? PostBlock::findOrFail($id)
: new PostBlock([
'type' => static::$postBlockType,
'post_id' => sharp()->context()->breadcrumb()->previousShowSegment('posts')->instanceId(),
'post_id' => sharp()->context()->breadcrumb()->previousShowSegment(PostEntity::class)->instanceId(),
]);

$this->save($postBlock, $data);
Expand Down
3 changes: 2 additions & 1 deletion demo/app/Sharp/Posts/Blocks/PostBlockPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\Post;
use App\Models\PostBlock;
use App\Sharp\Entities\PostEntity;
use Code16\Sharp\Auth\SharpEntityPolicy;

class PostBlockPolicy extends SharpEntityPolicy
Expand All @@ -17,6 +18,6 @@ public function view($user, $instanceId): bool
public function create($user): bool
{
return $user->isAdmin()
|| Post::find(sharp()->context()->breadcrumb()->previousShowSegment('posts')->instanceId())?->author_id === $user->id;
|| Post::find(sharp()->context()->breadcrumb()->previousShowSegment(PostEntity::class)->instanceId())?->author_id === $user->id;
}
}
3 changes: 2 additions & 1 deletion demo/app/Sharp/Posts/Blocks/PostBlockVisualsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Sharp\Posts\Blocks;

use App\Sharp\Entities\PostEntity;
use Code16\Sharp\Form\Eloquent\Uploads\Transformers\SharpUploadModelFormAttributeTransformer;
use Code16\Sharp\Form\Fields\SharpFormField;
use Code16\Sharp\Form\Fields\SharpFormListField;
Expand Down Expand Up @@ -37,7 +38,7 @@ protected function buildAdditionalFields(FieldsContainer $formFields): void
->setStorageBasePath(function () {
return sprintf(
'data/posts/%s/blocks/{id}',
sharp()->context()->breadcrumb()->previousShowSegment('posts')->instanceId(),
sharp()->context()->breadcrumb()->previousShowSegment(PostEntity::class)->instanceId(),
);
}),
)
Expand Down
5 changes: 3 additions & 2 deletions demo/app/Sharp/Posts/PostShow.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Models\Post;
use App\Sharp\Entities\AuthorEntity;
use App\Sharp\Entities\CategoryEntity;
use App\Sharp\Entities\PostBlockEntity;
use App\Sharp\Posts\Commands\EvaluateDraftPostWizardCommand;
use App\Sharp\Posts\Commands\PreviewPostCommand;
use App\Sharp\Utils\Embeds\AuthorEmbed;
Expand Down Expand Up @@ -63,7 +64,7 @@ protected function buildShowFields(FieldsContainer $showFields): void
)
)
->addField(
SharpShowEntityListField::make('blocks')
SharpShowEntityListField::make(PostBlockEntity::class)
->setLabel('Blocks')
->hideFilterWithValue('post', fn ($instanceId) => $instanceId)
);
Expand Down Expand Up @@ -92,7 +93,7 @@ protected function buildShowLayout(ShowLayout $showLayout): void
$column->withField('content');
});
})
->addEntityListSection('blocks');
->addEntityListSection(PostBlockEntity::class);
}

public function buildShowConfig(): void
Expand Down
Loading
Loading