Skip to content

Latest commit

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

This work is based on https://github.com/fumeapp/modeltyper, credit to them.

To use

  • Install pinia-orm if you haven't already npm i pinia-orm
  • Run artisan piniamodels:generate
  • Code will be generated into resources/js/models by default

Modifying

By default, hidden fields are excluded and all other fields, mutators and relationships are included

  • Create a new command
  • Add the following code
useDev1437\PiniaModelGenerator\PiniaModelsBuilder;
// Default$pmb = newPiniaModelsBuilder();
// Specify a different path e.g. to have the model put in resources/ts/pinia$pmb = newPiniaModelsBuilder(resource_path('ts/pinia')); // Generate code for specific modelsuseApp\Models\User;
useApp\Models\Post;
$pmb = newPiniaModelsBuilder(null, [], [
User::class,
Post::class
]);
// Specify options for specific model e.g. Include hidden fields and remove email_verified_at from UseruseApp\Models\User;
$pmb = newPiniaModelsBuilder(null, [
User::class => [
'ignoreHidden' => false,
'filters' => [
'email_verified_at',
],
]
]);
$pmb->buildModels();

Custom code in generated models

Each model contains two blocks

...
/* --- user header --- */
/* --- end user header --- */
...
/* --- user code --- */
/* --- end user code --- */
...

Any code written in these blocks will be persisted when the models are regenerated

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages