File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Illuminate \Database \Migrations \Migration ;
4+ use Illuminate \Database \Schema \Blueprint ;
5+ use Illuminate \Support \Facades \Schema ;
6+
7+ return new class extends Migration {
8+ public function up (): void
9+ {
10+ Schema::create ('cms_menus ' , function (Blueprint $ table ) {
11+ $ table ->id ();
12+
13+ if (config ('eclipse-cms.tenancy.enabled ' )) {
14+ $ tenantClass = config ('eclipse-cms.tenancy.model ' );
15+ /** @var \Illuminate\Database\Eloquent\Model $tenant */
16+ $ tenant = new $ tenantClass ;
17+ $ table ->foreignId (config ('eclipse-cms.tenancy.foreign_key ' ))
18+ ->constrained ($ tenant ->getTable (), $ tenant ->getKeyName ())
19+ ->cascadeOnUpdate ()
20+ ->cascadeOnDelete ();
21+ }
22+
23+ $ table ->string ('title ' );
24+ $ table ->boolean ('is_active ' )->default (true );
25+ $ table ->string ('code ' )->nullable ();
26+ $ table ->timestamps ();
27+ $ table ->softDeletes ();
28+ });
29+ }
30+
31+ public function down (): void
32+ {
33+ Schema::dropIfExists ('cms_menus ' );
34+ }};
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Illuminate \Database \Migrations \Migration ;
4+ use Illuminate \Database \Schema \Blueprint ;
5+ use Illuminate \Support \Facades \Schema ;
6+
7+ return new class extends Migration {
8+ public function up (): void
9+ {
10+ Schema::create ('cms_menu_items ' , function (Blueprint $ table ) {
11+ $ table ->id ();
12+ $ table ->string ('label ' );
13+ $ table ->foreignId ('menu_id ' )
14+ ->constrained ('cms_menus ' , 'id ' )
15+ ->cascadeOnUpdate ()
16+ ->cascadeOnDelete ();
17+ $ table ->string ('type ' );
18+ $ table ->string ('linkable_class ' );
19+ $ table ->string ('linkable_id ' );
20+ $ table ->boolean ('new_tab ' )->default (false );
21+ $ table ->boolean ('is_active ' )->default (true );
22+ $ table ->integer ('sort ' )->default (0 );
23+ $ table ->timestamps ();
24+ $ table ->softDeletes ();
25+ });
26+ }
27+
28+ public function down (): void
29+ {
30+ Schema::dropIfExists ('cms_menu_items ' );
31+ }
32+ };
Original file line number Diff line number Diff line change 22
33namespace Eclipse \Cms ;
44
5+ use Eclipse \Cms \Models \Page ;
6+ use Eclipse \Cms \Models \Section ;
7+ use Eclipse \Common \Foundation \Plugins \HasLinkables ;
58use Eclipse \Common \Foundation \Plugins \Plugin ;
69
7- class CmsPlugin extends Plugin
10+ class CmsPlugin extends Plugin implements HasLinkables
811{
9- //
12+ public function getLinkables (): array
13+ {
14+ return [
15+ Page::class => 'Page ' ,
16+ Section::class => 'Section ' ,
17+ ];
18+ }
1019}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Eclipse \Cms \Enums ;
4+
5+ use Filament \Support \Contracts \HasLabel ;
6+
7+ enum MenuItemType implements HasLabel
8+ {
9+ case Linkable;
10+ case CustomUrl;
11+ case Group;
12+
13+ public function getLabel (): ?string
14+ {
15+ return match ($ this ) {
16+ self ::Linkable => 'Data record ' ,
17+ self ::CustomUrl => 'Custom URL ' ,
18+ self ::Group => 'Group ' ,
19+ };
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Eclipse \Cms \Models ;
4+
5+ use Illuminate \Database \Eloquent \Model ;
6+ use Illuminate \Database \Eloquent \SoftDeletes ;
7+
8+ class Menu extends Model
9+ {
10+ use SoftDeletes;
11+
12+ protected $ fillable = [
13+ 'title ' ,
14+ 'is_active ' ,
15+ 'code ' ,
16+ ];
17+
18+ protected function casts (): array
19+ {
20+ return [
21+ 'is_active ' => 'boolean ' ,
22+ ];
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Eclipse \Cms \Models \Menu ;
4+
5+ use Eclipse \Cms \Models \Menu ;
6+ use Eclipse \Cms \Enums \MenuItemType ;
7+ use Illuminate \Database \Eloquent \Model ;
8+ use Illuminate \Database \Eloquent \Relations \BelongsTo ;
9+ use Illuminate \Database \Eloquent \SoftDeletes ;
10+
11+ class Item extends Model
12+ {
13+ use SoftDeletes;
14+
15+ protected $ table = 'cms_menu_items ' ;
16+
17+ protected $ fillable = [
18+ 'label ' ,
19+ 'menu_id ' ,
20+ 'type ' ,
21+ 'new_tab ' ,
22+ 'is_active ' ,
23+ 'sort ' ,
24+ ];
25+
26+ public function menu (): BelongsTo
27+ {
28+ return $ this ->belongsTo (Menu::class);
29+ }
30+
31+ protected function casts (): array
32+ {
33+ return [
34+ 'type ' => MenuItemType::class,
35+ 'new_tab ' => 'boolean ' ,
36+ 'is_active ' => 'boolean ' ,
37+ ];
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments