redroseamit
2 months ago
703
22
Laravel

update function is not working laravel 6 i am using resource controller

Posted 2 months ago by redroseamit

/* here is the controller */ public function update(Request $request, $id) {

    $categories = Categories::findOrFail($id);

    $this->validate($request, [
        'id' => 'required',
        'name' => 'required',
        'status' => 'required',
       
    ]);

    $input = $request->all();

    $categories->fill($input)->save();

    return redirect()->route('categories.index');
}

/*here is the form */

          <label for="id">ID:</label>
          <input type="text" class="form-control" value="{{$categories->id}}" name="id"/>
      </div>
      <div class="form-group">
          <label for="name">Name :</label>
          <input type="text" class="form-control" value="{{$categories->name}}" name="name"/>
      </div>
      <div class="form-group">
          <label for="status">status</label>
          <input type="text" class="form-control" value="{{$categories->status}}"  name="status"  />
      </div>
     
      <button type="submit" class="btn btn-primary">UPDATE</button>
  </form>

Please sign in or create an account to participate in this conversation.