99
1010This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
1111
12-
1312## Development
1413### Install inspirecms-support library
1514` COMPOSER_ROOT_VERSION=dev-main composer update `
@@ -31,238 +30,9 @@ npm i
3130npm run build
3231```
3332
34- ## Installation
35-
36- 1 . You can install the package via composer:
37-
38- ``` bash
39- composer require solution-forest/inspirecms-core
40- ```
41-
42- 2 . Run install command:
43- ``` bash
44- php artisan inspirecms:install
45- ```
46-
47- Optional: Install required default data:
48- ``` bash
49- php artisan inspirecms:import-default-data
50- ```
51-
52- 3 . Execute the schedule command to run scheduled jobs:
53- ``` bash
54- php artisan schedule:work
55- ```
56-
57- ### Existing scheduled jobs in the configuration file:
58- ``` php
59- 'scheduled_tasks' => [
60- 'execute_import_job' => [
61- 'enabled' => true,
62- 'schedule' => 'everyFiveMinutes',
63- 'command' => \SolutionForest\InspireCms\Commands\ExecuteImport::class,
64- 'arguments' => [
65- '--limit 50', // limit
66- ],
67- ],
68- 'data_cleanup' => [
69- 'enabled' => true,
70- 'schedule' => 'daily',
71- 'command' => \SolutionForest\InspireCms\Commands\DataCleanup::class,
72- ],
73- ],
74- ```
75-
76- ### Content Approving Flow
77- 1 . Add custom status
78- ``` php
79- \SolutionForest\InspireCms\Facades\ContentStatusManifest::replaceOption(
80- new \SolutionForest\InspireCms\DataTypes\Manifest\ContentStatusOption(
81- value: 5,
82- name: 'approved',
83- formAction: fn () => \Filament\Actions\Action::make('approved')
84- ->authorize('approved')
85- ->action(function (null | \SolutionForest\InspireCms\Models\Content $record, \Filament\Actions\Action $action, \SolutionForest\InspireCms\Base\Filament\Contracts $livewire) {
86-
87- // Handle your action here
88-
89- //Example:
90-
91- if (is_null($record)) {
92- $action->cancel();
93-
94- return;
95- }
96-
97- $publishableState = 'approved';
98-
99- if (! \SolutionForest\InspireCms\Helpers\ContentHelper::handlePublishableRecord($record, $publishableState, $livewire, [])) {
100- return;
101- }
102-
103- $action->success();
104-
105- }),
106- )
107- )
108- ```
109- 2 . Add policy for Content Model (Super admin already skip all guard)
110- ``` php
111- use \SolutionForest\InspireCms\Models\Content;
112-
113- /**
114- * Bootstrap any application services.
115- */
116- public function boot(): void
117- {
118- Gate::policy(Content::class, YourContentPolicy::class);
119- }
120- ```
121-
122- Or override ContentPublishPolicy on config
123- ``` php
124- // ...
125- 'models' => [
126- // ...
127- 'policies' => [
128- 'content' => YourContentPolicy::class,
129- ]
130- ],
131- //...
132- ```
133-
134- ``` php
135- use Illuminate\Contracts\Auth\Authenticatable;
136- use Illuminate\Database\Eloquent\Model;
137- use SolutionForest\InspireCms\Models\Contracts\Content;
138-
139- class YourContentPolicy
140- {
141- /**
142- * @param Authenticatable|User|Model $user
143- * @param null|Content|Model $content
144- * @return bool
145- */
146- public function approved($user, $content)
147- {
148- return true;
149- }
150- }
151- ```
152-
153- 3 . Override the ` Content ` model to update the condition that determines if the content is published.
33+ ## Documentation
15434
155- ``` php
156- use SolutionForest\InspireCms\Models\Content as BaseModel;
157- use SolutionForest\InspireCms\Models\Contracts\Content as ContentContract;
158-
159- class Content extends BaseModel implements ContentContract
160- {
161- public function isPublished(): bool
162- {
163- // Your implementation here
164- }
165-
166- public function scopeWhereIsPublished($query, bool $condition = true)
167- {
168- // Your implementation here
169- }
170- }
171- ```
172-
173- ### Adding extract filament cluster/resource/page
174-
175- > [ !IMPORTANT]
176- > need add back miss permission after cluster/resource/page added.
177-
178- Execute the command:
179- ``` bash
180- php artisan inspirecms:repair-permissions
181- ```
182-
183- #### Adding extract filament cluster
184-
185- - Option 1: create by ` make:filament-cluster xxx --panel=cms `
186- - Option 2: create you cluster, and add this to ` filament.cluster ` on config file.
187-
188- 1 . After cluster created, please apply ` ClusterSectionTrait ` and ` ClusterSection ` to your resource.
189- ``` php
190- use Filament\Clusters\Cluster;
191- use SolutionForest\InspireCms\Filament\Concerns\ClusterSectionTrait;
192- use SolutionForest\InspireCms\Filament\Contracts\ClusterSection;
193-
194- class Test extends Cluster implements ClusterSection
195- {
196- use ClusterSectionTrait;
197- }
198- ```
199-
200- #### Adding extract filament resource
201- - Option 1: create by ` make:filament-resource xxx --panel=cms `
202- - Option 2: create you resource, and add this to ` filament.resources ` on config file.
203-
204- After resource created, please apply ` ClusterSectionResource ` , ` ClusterSectionResourceTrait ` , and Cluster to your resource.
205-
206- > [ !IMPORTANT]
207- > Ensure your Cluster apply SolutionForest\InspireCms\Filament\Contracts\ClusterSection interface.
208-
209- ``` php
210- use Filament\Resources\Resource;
211- use SolutionForest\InspireCms\Filament\Concerns\ClusterSectionResourceTrait;
212- use SolutionForest\InspireCms\Filament\Contracts\ClusterSectionResource;
213-
214- class TestResource extends Resource implements ClusterSectionResource
215- {
216- use ClusterSectionResourceTrait;
217-
218- protected static ?string $cluster = \App\Clusters\Test::class;
219- }
220- ```
221-
222- #### Adding extract filament page
223- - Option 1: create by ` make:filament-page xxx --panel=cms `
224- - Option 2: create you page, and add this to ` filament.pages ` on config file.
225-
226- After page created, please apply ` ClusterSectionPage ` , ` ClusterSectionResourceTrait ` , ` GuardPage ` , and Cluster to your resource.
227-
228- > [ !IMPORTANT]
229- > Ensure your Cluster apply SolutionForest\InspireCms\Filament\Contracts\ClusterSection interface.
230-
231- use SolutionForest\InspireCms\Filament\Concerns\ClusterSectionPageTrait;
232- use SolutionForest\InspireCms\Filament\Contracts\ClusterSectionPage;
233- use SolutionForest\InspireCms\Filament\Contracts\GuardPage;
234-
235- ``` php
236- class Test extends Page implements ClusterSectionPage, GuardPage
237- {
238- use ClusterSectionPageTrait;
239-
240- protected static ?string $cluster = \App\Clusters\Test::class;
241-
242- public static function getPermissionName(): string
243- {
244- return 'view_test_page';
245- }
246-
247- public static function getPermissionDisplayName(): string
248- {
249- return 'View test page';
250- }
251- }
252- ```
253-
254- ## Extending
255-
256- ### Override model
257- ``` php
258- public function register(): void
259- {
260- \SolutionForest\InspireCms\Facades\ModelManifest::replace(
261- \SolutionForest\InspireCms\Models\Contracts\Content::class,
262- Your\Model\Class::class,
263- );
264- }
265- ```
35+ For additional documentation, please see [ Document] ( ./docs/Documentation.md ) .
26636
26737## Testing
26838
0 commit comments