1

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:

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

1 Answers1

1

Don't use both get() and all() in the same time. It should be:

public function edit($name)
{

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

    [...]

}
violator667
  • 469
  • 4
  • 19
  • [get VS All](https://stackoverflow.com/questions/34587457/difference-between-eloquent-modelget-and-all) check this first – Mahdi Bahari Aug 14 '19 at 08:53