Get the App
SLTechnology News&Howtos  ›  Development  › 

How to export the data of data table and generate seeds seed file by Laravel

Shulou Source: shulou.com Published: 2022-06-01 02:30:59 10月04日 Update

This article is a detailed introduction to "how Laravel exports the data of the data table and generates the seeds seed file". The content is detailed, the steps are clear, and the details are properly handled. I hope this article "how Laravel exports the data of the data table and generates the seeds seed file" can help you solve your doubts. Let's go deeper and learn new knowledge together with the ideas of the small editor.

Install isseed

Install isseed. I have laravel 5.4 here. The installed iseed is version 2.1. You can see the situation. Feel free.

composer require "orangehill/iseed": "2.1"

Add iseed to the composer.json file

Add iseed to service provider

Add providers to laravel project directory config/app.php

'providers' => [ ... Orangehill\Iseed\IseedServiceProvider::class,],

Update composer command line execution

composer update

This is the end of installation

Iced usage

Export data for a single table

For example, if I want to export the data of a table to a seed file, then the command is: php artisan iseed The table name you want to convert

If I want to export data from a user table, the command would be:

php artisan iseed users

Export data from multiple tables

Similar to exporting a single, multiple tables separated by commas

php artisan iseed Table 1, Table 2

Export data and force overwrite

Sometimes when we export, the seed file already exists and we have to overwrite it. How do we do that?

It's very simple. Everything else remains the same. Just add--force to the command and it's OK.

php artisan isedtable name1 [, tablename2...]-- force

Export specified tables from specified databases and generate seed files

php artisan iseed table name--database= database name Read here, this article "Laravel how to export the data table and generate seeds seed file" article has been introduced, want to master the knowledge of this article also need to practice to understand, if you want to know more about the content of the article, welcome to pay attention to the industry information channel.

Tags: Data files generation commands data tables seeds articles content single multiple I want database proper ideas situations providers new knowledge time more sometimes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Apple Linux MariaDB NVidia