File tree Expand file tree Collapse file tree 2 files changed +32
-17
lines changed
Expand file tree Collapse file tree 2 files changed +32
-17
lines changed Original file line number Diff line number Diff line change 1111use Javaabu \Cms \Enums \GalleryTypes ;
1212use Javaabu \Cms \Enums \PageStyles ;
1313use Javaabu \Helpers \Enums \PublishStatuses ;
14+ use Javaabu \Translatable \Contracts \Translatable ;
15+ use Javaabu \Translatable \JsonTranslatable \IsJsonTranslatable ;
1416use Javaabu \Translatable \Models \Language ;
1517
16- class Post extends Model
18+ class Post extends Model implements Translatable
1719{
20+ use IsJsonTranslatable;
21+
1822 protected static $ status_class = PublishStatuses::class;
1923
2024 /**
@@ -73,21 +77,27 @@ class Post extends Model
7377
7478 protected $ with = ['postType ' ];
7579
76- // public function getTranslatables(): array
77- // {
78- // return [
79- // 'title',
80- // 'content',
81- // 'excerpt',
82- // ];
83- // }
84- // public function getNonTranslatablePivots(): array
85- // {
86- // return [
87- // 'categories',
88- // 'tagWords',
89- // ];
90- // }
80+ public function getTranslatables (): array
81+ {
82+ if (! config ('cms.should_translate ' )) {
83+ return [];
84+ }
85+ return [
86+ 'title ' ,
87+ 'content ' ,
88+ 'excerpt ' ,
89+ ];
90+ }
91+ public function getNonTranslatablePivots (): array
92+ {
93+ if (! config ('cms.should_translate ' )) {
94+ return [];
95+ }
96+ return [
97+ 'categories ' ,
98+ 'tagWords ' ,
99+ ];
100+ }
91101
92102 public static function boot ()
93103 {
@@ -190,7 +200,6 @@ public function postType(): BelongsTo
190200 }
191201
192202
193-
194203 /**
195204 * A search scope
196205 *
Original file line number Diff line number Diff line change 22
33namespace Javaabu \Cms \Models ;
44
5+ use Illuminate \Database \Eloquent \Relations \BelongsTo ;
56use Javaabu \Helpers \AdminModel \AdminModel ;
67use Javaabu \Helpers \AdminModel \IsAdminModel ;
78use Illuminate \Database \Eloquent \Model ;
@@ -56,5 +57,10 @@ public function getTranslatables(): array
5657 'og_description ' ,
5758 ];
5859 }
60+
61+ public function categoryType (): BelongsTo
62+ {
63+ return $ this ->belongsTo (CategoryType::class);
64+ }
5965}
6066
You can’t perform that action at this time.
0 commit comments