dsilhx5830 2017-07-24 21:15
浏览 22

(1/1)ErrorException未定义索引:ClientController.php中的id(第81行)

I am not sure why I am getting this error. Here is the method in the ClientController.

protected function updateOneStudent($parameters)
{
  $studentId = $parameters['id'];
  return $this-  >performPutRequest("https://lumenapi.juandmegon.com/students/{$studentId}", $parameters);
}

Basically I am trying to update a selected student. Below is the update form.

@extends('layouts.master')

 @section('content')
 <form action="{{url('/student/update')}}" method="POST" role="form">
     {{ csrf_field() }}

{{method_field('PUT')}}
<legend>Create a Student</legend>
<div class="form-group">
  <label for="">Name</label>
  <input type="text" class="form-control" name="name" value="{{$student->name }}"required="required">
</div>
<div class="form-group">
  <label for="">Address</label>
  <input type="text" class="form-control" name="address" value="{{$student->address }}" required="required">
</div>
<div class="form-group">
  <label for="">Phone</label>
  <input type="text" class="form-control" name="phone" value="{{$student->phone }}" required="required">
</div>
<div class="form-group">
  <label for="">Career</label>
  <select name="career" class="form-control" required="required">
    <option>Select a Career</option>
    <option value="math"{{$student->career == 'math' ? 'selected' : ''}}>Math</option>
    <option value="physics"{{$student->career == 'physics' ? 'selected' : ''}}>Physics</option>
    <option value="engineering"{{$student->career == '' ? 'engineering' : ''}}>Engineering</option>
  </select>
</div>
<button type="submit" class="btn btn-primary">Update Student</button>
</form>

  @endsection
  • 写回答

1条回答 默认 最新

  • dongzhucha3999 2017-07-24 22:04
    关注

    The request I was sending was wrong. The error was in the StudentController. I had

    public function getUpdateStudent()
    {
      $students = $this->obtainAllStudents;
      return view('students.select-student', ['students'=> $students]);
    }
    

    It it should have been

    public function getUpdateStudent()
    {
      $students = $this->obtainAllStudents();
      return view('students.select-student', ['students'=> $students]);
    }
    

    I missed the brackets to call the getUpdateStudent. Sorry guys I did not show this code earlier.

    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序