使用代码路径播种数据库? [英] Seeding database with path from code?

查看:64
本文介绍了使用代码路径播种数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在将Laravel的迁移与path参数一起使用,如下所示:

I've been using Laravel's migrations with the path parameter like so:

Artisan::call('migrate', array('--path' => 'path/to/my/Migrations'));

无论如何,我是否可以以相同的方式运行seed命令?我有很多要使用的种子文件,但我不想同时运行它们.

Is there anyway I can run the seed command in the same way? I have a number of seed files I want to use but I don't want to run them all at the same time.

任何建议表示赞赏.

谢谢

推荐答案

您可以将带有命名空间的--class设置为Seeder类,而不是--path.

Instead of --path you can set --class with namespace to Seeder class.

Artisan::call('db:seed', [
    '--class' => 'Namespace\Seeds\DatabaseSeeder'
]);

有关Laravel 5.1的工作

This work on Laravel 5.1

这篇关于使用代码路径播种数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆