Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
452 views
in Technique[技术] by (71.8m points)

laravel - Missing required parameters for [Route: bricks.update] [URI: bricks/{brick}]. (View: /home/Development/ad-et/resources/views/bricks/edit.blade.php)

I'm using Laravel 7 and got stuck since few days!

Controller:

public function edit(Bricks $bricks)
{
    return view('bricks.edit', compact('bricks'));
}

Routes:

Route::resource('bricks','BricksController');

Index:

<a href="{{ route('bricks.edit',$item->id) }}" class="btn btn-sm btn-warning btn-circle">
      EDIT
</a>

edit blade file:

       <form action="{{ route('bricks.update',$bricks->id) }}" method="POST">
        @csrf
        @method('PUT')
          <div class="box-body">
            <div class="form-group">
              <label for="">Vehicle Number</label>
              <input name="vehicle_number" value="{{ $bricks->vehicle_number }}" type="name" class="form-control" id="" placeholder="Enter Vehicle Number">
            </div>
            <div class="form-group">
              <label for="">Bill Number</label>
              <input name="bill_number" value="{{ $bricks->bill_number }}" type="name" class="form-control" id="" placeholder="Enter Bill Number">
            </div>
            <div class="form-group">
              <label for="">Per Unit Rate</label>
              <input name="per_unit_rate" value="{{ $bricks->per_unit_rate }}" type="number" class="form-control" id="" placeholder="Enter Per Unit Rate">
            </div>
            <div class="form-group">
              <label for="">Total Units</label>
              <input name="total_units" value="{{ $bricks->total_units }}" type="number" class="form-control" id="" placeholder="Enter Total Units">
            </div>
            <div class="form-group">
              <label for="">Total Rate</label>
              <input name="total_rate" value="{{ $bricks->total_rate }}" type="number" class="form-control" id="" placeholder="Enter Total Rate">
            </div>
          </div>
          <!-- /.box-body -->
          <div class="box-footer">
            <button type="submit" class="btn btn-primary">Update This Entry</button>
          </div>
        </form>

I just added the edit.blade.php file in which the error is occuring!

question from:https://stackoverflow.com/questions/65952134/missing-required-parameters-for-route-bricks-update-uri-bricks-brick-v

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
public function edit(Bricks $brick)
{
    return view('bricks.edit', compact('brick'));
}

and change the variable in the view file too.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...