Skip to content

Casing Configurations

The Laravel TypeScript Publisher provides three independent config options to control the casing of generated property and method names — one for model relationship names, one for enum method names, and one for route action names. All three accept 'snake', 'camel', or 'pascal', and each only affects its own feature; there's no single global casing setting.

As mentioned in Installation & Usage, these are plain config values with no attribute or runtime component involved.

models.relationship_case

Controls relationship names in generated model TypeScript interfaces — see Models for the full relation-generation behavior.

php
// config/ts-publish.php

'models' => [
    'relationship_case' => 'snake', // default
],
Config ValueRelationship hasMany(Post::class)CountExists
'snake'posts: Post[]posts_countposts_exists
'camel'posts: Post[]postsCountpostsExists
'pascal'Posts: Post[]PostsCountPostsExists

NOTE

For each relationship defined on a model, this package automatically generates _count and _exists properties alongside the relation itself. These correspond to Laravel's withCount and withExists features and are included in every generated model interface.

enums.method_case

Controls the casing of enum method and static method key names in the generated TypeScript output — see Enums for the full method-inclusion behavior (#[TsEnumMethod], #[TsEnumStaticMethod], and the auto_include_methods / auto_include_static_methods config).

php
// config/ts-publish.php

'enums' => [
    'method_case' => 'camel', // default
],
Config ValueMethod getLabel()Static Method AllLabels()
'snake'get_labelall_labels
'camel'getLabelallLabels
'pascal'GetLabelAllLabels

TIP

This setting applies to all enum methods — both instance methods (via #[TsEnumMethod] or enums.auto_include_methods) and static methods (via #[TsEnumStaticMethod] or enums.auto_include_static_methods). You can still override an individual method's name using the name parameter on the attribute, regardless of this setting.

routes.method_casing

Controls the casing of each generated route action's exported identifier — see Routing for the full route-generation behavior. This only affects the generated variable/export name; it never changes the underlying Laravel route name (route()/Ziggy calls still use the original route name).

php
// config/ts-publish.php

'routes' => [
    'method_casing' => 'camel', // default
],
Config ValueController method updateProfile()Controller method store()
'snake'update_profilestore
'camel'updateProfilestore
'pascal'UpdateProfileStore

NOTE

If the casing transformation produces a reserved JavaScript/TypeScript keyword (e.g. a method named delete), the export name is automatically suffixed with Method (e.g. deleteMethod) to stay a valid identifier.

Configuration Reference

Config KeyTypeDefaultDescription
models.relationship_casestring'snake'Casing for relation names and their _count / _exists properties
enums.method_casestring'camel'Casing for enum instance/static method key names
routes.method_casingstring'camel'Casing for each route action's exported identifier

The full list of models.*, enums.*, and routes.* config keys lives in the Configuration Reference.

Released under the MIT License.