laravel 如何在laravel 4.2中将可填充变量作为数组获取
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39859983/
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
How to get fillable variable as array in laravel 4.2
提问by patricus
When we create any Model class we create protected variable fillable
当我们创建任何模型类时,我们会创建受保护的变量 fillable
I use this like
我用这个
$model = new Demo;
$model->fillable // but now working
$model->fillable() // but now working.
Actually i want to loop over that variable
其实我想遍历那个变量
But i don't want to create any extra variable and don't wanto to change variable
但我不想创建任何额外的变量,也不想改变变量
type from protected to public.
类型从保护到公共。
Thanks in Advance....
提前致谢....
回答by patricus
Models have a getFillable()
method that will return the value of the $fillable
property.
模型有一个getFillable()
方法可以返回$fillable
属性的值。
$model = new Demo();
dd($model->getFillable());