I'm building a web application using Laravel 5. The tutorial I followed started with no data.
-
Create migrate table.
It uses:
php artisan make:migration create_table-name_tables --create="table_name"
-
Set up schema
Then set up table schema in /database/migrations/_create_table-name_tables.php .
-
Perform migration:
php artisan migrate
. -
Seeders.
Create /database/seeds/table-nameTableSeeder.php. In this file there is actual rows in the table defined.
-
Add seed class to /database/seeds/DatabaseSeeder.php:
use Illuminate\Database\Seeder; use Illuminate\Database\Eloquent\Model; class DatabaseSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); $this->call('Table-nameTableSeeder'); } }
-
Seed with:
composer dump-autoload php artisan db:seed
My question: If I already have a existing database. How do I modify migration steps to use my database? Do I just need to do step 1,2 and 3? Then I can move on to Creating models?
Thanks in advance!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire