• Reading time ~ 1 min
  • 11.02.2023

Model JSON for Laravel is a package that allows you to easily export data from specific models in your Laravel application to JSON format. It is based on the php artisan command and offers various options to customize the export process. This package helps export important data from your models in a convenient format:

php artisan model:export User

# Or specify the exact model location
php artisan model:export App\Models\User

# Exclude fields
php artisan model:export User --except-fields=id,deleted_at

This package also supports associated model data using the following flag:

php artisan model:export Product \
  --with-relationships=category

# Like before, specify which fields to export
# on the relationship
php artisan model:export Product \
  --with-relationships=category:id,name

Lastly, you can import data from a JSON file and store it in your database:

php artisan model:import User path/to/Users.json

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Comments

No comments yet
Yurij Finiv

Yurij Finiv

Full stack

ABOUT

Professional Fullstack Developer with extensive experience in website and desktop application development. Proficient in a wide range of tools and technologies, including Bootstrap, Tailwind, HTML5, CSS3, PUG, JavaScript, Alpine.js, jQuery, PHP, MODX, and Node.js. Skilled in website development using Symfony, MODX, and Laravel. Experience: Contributed to the development and translation of MODX3 i...

About author CrazyBoy49z
WORK EXPERIENCE
Contact
Ukraine, Lutsk
+380979856297