laravel 5 编辑 Elequent 不工作

laravel 5 edit elequent not working

我正在尝试使用以下 Elequent 编辑我的数据字段,但它没有获取数据,感谢任何帮助。

以下是我使用的数据控制器:

  public function edit($name)
{

    $category = category::where('name', $name)->get()->all();

    dd($category);

    return view('/editcategory')->with('category', $category);

}

在检查输出时它没有从数据库中获取数据 输出:

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
  }
]

不要同时使用 get()all()。 应该是:

public function edit($name)
{

    $category = category::where('name', $name)->all();

    [...]

}