File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33namespace Javaabu \Cms \Models ;
44
55use Illuminate \Database \Eloquent \Relations \BelongsTo ;
6+ use Illuminate \Support \Str ;
7+ use Javaabu \Cms \Enums \PostTypeFeatures ;
68use Javaabu \Helpers \AdminModel \AdminModel ;
79use Javaabu \Helpers \AdminModel \IsAdminModel ;
810use Illuminate \Database \Eloquent \Model ;
@@ -62,5 +64,38 @@ public function categoryType(): BelongsTo
6264 {
6365 return $ this ->belongsTo (CategoryType::class);
6466 }
67+
68+ public function getFeatureName ($ feature ): ?string
69+ {
70+ if (! $ this ->hasFeature ($ feature )) {
71+ return null ;
72+ }
73+
74+ $ feature_title = $ this ->features [$ feature ];
75+
76+ if (gettype ($ feature_title ) == 'boolean ' ) {
77+ return PostTypeFeatures::getLabel ($ feature );
78+ }
79+
80+ if (gettype ($ feature_title ) == 'string ' ) {
81+ return Str::title ($ feature_title );
82+ }
83+
84+ return null ;
85+ }
86+
87+ public function hasFeature ($ feature ): bool
88+ {
89+ return array_key_exists ($ feature , $ this ->features );
90+ }
91+
92+ public function getFeatureCollectionName ($ feature ): ?string
93+ {
94+ if (! $ this ->hasFeature ($ feature )) {
95+ return null ;
96+ }
97+
98+ return PostTypeFeatures::getCollectionName ($ feature );
99+ }
65100}
66101
You can’t perform that action at this time.
0 commit comments