I'd like to define a BaseDataResource class that has some useful methods for all my data classes. However, this is a base class, it is not itself related to any particular model.
Unfortunately, it looks like Momentum Lock will transform all classes extending DataResource, regardless of the missing #[Typescript]. This creates a problem when my base data class is inside the auto-discovery path, as the transformer will throw an error:
Class name must be a valid object or a string
at vendor/based/momentum-lock/src/TypeScript/DataResourceTransformer.php:24
20▕ if (! $abilities) {
21▕ $modelClass = $class->getProperty('modelClass')->getDefaultValue();
22▕
23▕ /** @var \Illuminate\Database\Eloquent\Model $model */
➜ 24▕ $model = new $modelClass;
25▕
26▕ $abilities = Lock::getAbilitiesFromPolicy($model);
27▕ }
28▕
Ideally, I should be able to control wether the class is transformed at all by using the #[Typescript] property on the class.
I'd like to define a
BaseDataResource
class that has some useful methods for all my data classes. However, this is a base class, it is not itself related to any particular model.Unfortunately, it looks like Momentum Lock will transform all classes extending
DataResource
, regardless of the missing#[Typescript]
. This creates a problem when my base data class is inside the auto-discovery path, as the transformer will throw an error:Ideally, I should be able to control wether the class is transformed at all by using the
#[Typescript]
property on the class.