[英]laravel 5 edit elequent not working
I am trying to edit my data field with following elequent but its not picking up the data, any help appreciated. 我正在尝试使用以下元素来编辑我的数据字段,但是它没有获取数据,感谢任何帮助。
following is the data controller i am using: 以下是我正在使用的数据控制器:
public function edit($name)
{
$category = category::where('name', $name)->get()->all();
dd($category);
return view('/editcategory')->with('category', $category);
}
while checking the output it not picking up the data from the db output: 在检查输出时,它没有从db输出中获取数据:
array:1 [▼
0 => category {#190 ▼
#table: "category"
#connection: null
#primaryKey: "id"
#perPage: 15
+incrementing: true
+timestamps: true
#attributes: array:5 [▶]
#original: array:5 [▶]
#relations: []
#hidden: []
#visible: []
#appends: []
#fillable: []
#guarded: array:1 [▶]
#dates: []
#dateFormat: null
#casts: []
#touches: []
#observables: []
#with: []
#morphClass: null
+exists: true
}
]
Don't use both get()
and all()
in the same time. 不要同时使用
get()
和all()
。 It should be: 它应该是:
public function edit($name)
{
$category = category::where('name', $name)->all();
[...]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.