Laravel 4 - 迁移“蓝图”的含义?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18124186/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 4 - Migrations 'Blueprint' meaning?
提问by BigJobbies
I need a bit of advice.
我需要一些建议。
I have a few migrations files in my setup.
我的设置中有一些迁移文件。
In some of them im seeing the following code which arent in the rest and im not sure what its for
在其中一些我看到以下代码,其余代码中没有,我不确定它的用途
use Illuminate\Database\Schema\Blueprint;
Schema::create('brand', function(Blueprint $table)
Could anyone tell me what the blueprint lines are for? as they arent in the other create table migrations.
谁能告诉我蓝图线是做什么用的?因为它们不在其他创建表迁移中。
Thanks
谢谢
采纳答案by Jan P.
This is because in your closure the parameter $table
is tagged to be a Blueprint
object. In fact every time a Blueprint
is passed into the closure of Schema::create
.
So you can restrict the parameter to Blueprint
then PHP throws an fatal if an object of an other type is passed, or you can leave it blank so that PHP doesn't check the passed object.
这是因为在您的闭包中,参数$table
被标记为一个Blueprint
对象。事实上,每次 aBlueprint
被传递到Schema::create
. 因此,您可以将参数限制为Blueprint
如果传递了其他类型的对象,则 PHP 会抛出致命错误,或者您可以将其留空,以便 PHP 不检查传递的对象。
Just look up the files where the use
-Statement is missing. There will be no parameter constraint.
只需查找use
缺少 -Statement的文件即可。将没有参数约束。