У меня есть проблема, но я не могу найти ее решение.
Отображается следующая ошибка:
Фасад \ Ignition \ Exceptions \ ViewException Отсутствуют обязательные параметры для [ Маршрут: settings.networks.update] [URI: настройки / сети / {сеть}]. (Представление: C: \ xampp \ htdocs \ patom \ layout \ resources \ views \ settings \ networks \ edit.blade. php) http://localhost: 8000 / settings / networks / 5 / edit
Мой контроллер:
/**
* Show the form for editing the specified resource.
*
* @param \App\Network $network
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$network = Network::find($id);
return view('settings.networks.edit', compact('network'));
}
Мое изменение:
@extends('layouts.dashboard')
@section('content')
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1>Update Network</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ route('dashboard') }}">Home</a></li>
<li class="breadcrumb-item active">Networks</li>
</ol>
</div>
</div>
</div><!-- /.container-fluid -->
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-12">
<!-- Horizontal Form -->
<div class="card card-info">
<div class="card-header">
<h3 class="card-title">Please fill all (*)</h3>
</div>
<!-- /.card-header -->
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<!-- form start -->
<form action="{{ route('settings.networks.update') }}" method="POST" class="form-horizontal">
@method('PATCH')
@csrf
<div class="card-body">
<div class="form-group row">
<label for="name" class="col-sm-2 col-form-label">Name:</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="name" name="name" value="{{ $network->name }}">
</div>
</div>
<div class="form-group row">
<label for="own_network_id" class="col-sm-2 col-form-label">Network ID:</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="own_network_id" name="own_network_id" value="{{ $network->own_network_id }}">
</div>
</div>
</div>
<!-- /.card-body -->
<div class="card-footer">
<button type="submit" class="btn btn-info">Update</button>
<button type="submit" class="btn btn-default float-right">Cancel</button>
</div>
<!-- /.card-footer -->
</form>
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@endsection
Мой индекс:
|@foreach($networks as $network)
<tr>
<td>{{ $network->id }}</td>
<td>{{ $network->name }}</td>
<td><div class="btn-toolbar pull-right">
<a href="{{ route('settings.networks.edit', $network->id) }}"><button type="button" class="btn btn-success mr-3">Edit</button></a>
<form action="{{ route('settings.networks.destroy', $network->id) }}" method="POST">
@csrf
{{ method_field('DELETE') }}
<button type="submit" class="btn btn-danger mr-3">Delete</button>
</form>
</div>
</td>
</tr>
@endforeach
Мой маршрут:
Route::namespace('Settings')->prefix('settings')->name('settings.')->group(function(){
Route::resource('/networks', 'NetworksController', ['except' => ['show']]);
});