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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 08:14:42  来源:igfitidea点击:

Laravel 4 - Migrations 'Blueprint' meaning?

laravellaravel-4

提问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 $tableis tagged to be a Blueprintobject. In fact every time a Blueprintis passed into the closure of Schema::create. So you can restrict the parameter to Blueprintthen 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的文件即可。将没有参数约束。