我正在使用laravel4开发我的项目之一。我有一个迁移文件,我想在其中添加未选中的项,或者默认情况下使用错误的复选框列来添加admin的批准功能。所以我的问题很简单,那就是如何添加未选中的项迁移文件中的“复选框”列。
这是我的婚姻移转档案,
Schema::create('marriages', function(Blueprint $table)
{
$table->increments('id');
------------------------ // field for unchecked checkbox column
$table->string('candidate_name',255)->unique();
$table->string('email',255)->unique();
$table->string('father_name',60);
$table->string('mother_name',60);
$table->date('date_of_birth');
$table->string('sex',60);
$table->string('location',255);
$table->string('blood_group',20);
$table->string('religion',60);
$table->string('present_address',255);
$table->string('permanent_address',60);
$table->string('height',100)->nullable();
$table->string('complexion',100);
$table->string('nationality',100);
$table->string('educational_qualification',255);
$table->string('occupation',255);
$table->integer('phone_number');
$table->integer('number_of_bro_sis');
$table->string('image',255);
$table->timestamps();
});
更新:
现在我该如何在我的模板中检查它,我想显示该字段的结果,该结果实际上已被批准,我应该使用
@if($results->approved(true))
then show the results object
还是我应该使用其他东西?
没有“复选框”列之类的东西。您可能正在谈论一个布尔值,从技术上讲,它是一个tinyint(假设您使用MySQL)
这是您添加一个的方法:
$table->boolean('approved');
通常默认值应该是false
now,但是要确保:
$table->boolean('approved')->default(false);
这是所有架构构建器列方法的完整参考
如果您想使用$results->approved(true)
或$results->approved()
必须向模型中添加自定义函数。
但是,您可以更轻松地完成此操作
@if($results->approved == true)
甚至省略,== true
因为if会检查“真实”值
@if($results->approved)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句