Skip to content

Releases: vildanbina/laravel-model-json

v2.1

04 Aug 07:17
Compare
Choose a tag to compare

replace hardcoded backslash with DIRECTORY_SEPARATOR for cross-platform compatibility

Adding a feature to import Models with relationships together

22 Apr 16:53
Compare
Choose a tag to compare

This package introduces a new feature that allows importing models along with their relationships from JSON. The supported relationship types include HasOne, HasMany, HasOneThrough, HasManyThrough, MorphOne, MorphMany, MorphToMany, MorphTo, BelongsTo, and BelongsToMany. You can import models with their relationships using the --with-relationships={relations} option, where {relations} represent the names of the relationships and can be separated by + if you want to attach multiple relationships.

For instance, if you want to import a Category model with its Product relationship, you can use the command:

php artisan model:import Category public/Categories.json --with-relationships=products

If you want to import a Category model along with both its Product and User relationships, you can use the command:

php artisan model:import Category public/Categories.json --with-relationships=products+user

Moreover, you can selectively import columns of the relationship using the syntax {relationship_name}:{columns_to_import}.

For example, if you want to import a Category model along with its Product relationship and only import the id and name columns of the Product, you can use the command:

php artisan model:import Category public/Categories.json --with-relationships=products:id,name

Note: that in addition to the assignment made while importing a product to a category with relationships, the Category model will also be updated with the attributes found in the JSON.

Fix issue on importing

20 Mar 12:00
Compare
Choose a tag to compare

fixing a bug on importing with exsiting keys by modifying the variable name

v1.0

29 Jan 22:41
Compare
Choose a tag to compare
update README.md