3 回答
TA贡献1936条经验 获得超6个赞
在 web.php 中
Route::patch('edit-empresa/{id}', 'Admin\EmpresaController@update');
索引.blade.php
@method('PATCH')
TA贡献1790条经验 获得超9个赞
POST
即使您将其包含在表单内部,您也需要在定义表单时指定方法@method('PUT')
。这是因为 HTML 不PUT
直接支持方法,默认情况下它将是一个GET
. 所以更正一下:
改变这个:
<form action="edit-empresa/" id="editForm">
到
<form action="edit-empresa/" id="editForm" method="POST">
TA贡献1890条经验 获得超9个赞
由于某种原因,我无法使用模态和 jquery 方法使其工作,因此我从 index.blade.php 底部删除了数据表 jquery。我的第一个错误是没有先调用数据。我在 view-admin-empresa 文件夹中创建了一个名为 edit.blade.php 的单独文件。这是代码:
@extends('layouts.admin')
@section('content')
<div class="container-fluid mt-5">
<!-- Heading -->
<div class="card mb-4 wow fadeIn">
<!--Card content-->
<div class="card-body d-sm-flex justify-content-between">
<h4 class="mb-2 mb-sm-0 pt-1">
<span>Empresa Registrada - Editar Empresa</span>
</h4>
</div>
</div>
<!-- Heading -->
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h4 class="card-title">Editar Empresa</h4>
<form action="{{ url('empresa-update/'.$empresa->id) }}" id="editForm" method="POST">
{{ csrf_field() }}
{{ method_field('PUT') }}
<div class="modal-body mx-3">
<div class="md-form mb-1">
<label for="erfc">RFC</label>
<input value="{{ $empresa->erfc }}" type="text" name="erfc" id="erfc" class="form-control validate">
</div>
<div class="md-form mb-1">
<label for="enombre">Nombre</label>
<input value="{{ $empresa->enombre }}" type="text" name="enombre" id="enombre" class="form-control validate">
</div>
<div class="md-form mb-1">
<label for="ecalle">Calle</label>
<input value="{{ $empresa->ecalle }}" type="text" name="ecalle" id="ecalle" class="form-control validate">
</div>
<div class="md-form mb-1">
<label for="ecolonia">Colonia</label>
<input value="{{ $empresa->ecolonia }}" type="text" name="ecolonia" id="ecolonia" class="form-control validate">
</div>
<div class="md-form mb-1">
<label for="ecuidad">Ciudad</label>
<input value="{{ $empresa->eciudad }}" type="text" name="eciudad" id="eciudad" class="form-control validate">
</div>
<div class="md-form mb-1">
<label for="eestado">Estado</label>
<input value="{{ $empresa->eestado }}" type="text" name="eestado" id="eestado" class="form-control validate">
</div>
<div class="md-form mb-1">
<label for="ecpostal">Codigo Postal</label>
<input value="{{ $empresa->ecpostal }}" type="text" name="ecpostal" id="ecpostal" class="form-control validate">
</div>
<div class="md-form mb-1">
<label for="epais">País</label>
<input value="{{ $empresa->epais }}" type="text" name="epais" id="epais" class="form-control validate">
</div>
<div style="display: none;" class="md-form mb-1">
<input type="text" name="euser" readonly id="euser" class="form-control validate" value="{{ Auth::user()->id }}">
</div>
<div style="display: none;" class="md-form mb-1">
<input type="text" name="eregby" readonly id="eregby" class="form-control validate" value="{{ Auth::user()->id }}">
</div>
</div>
<div class="modal-footer d-flex justify-content-center">
<a href="{{ url('registered-empresa') }}" class="btn btn-secondary">Cancelar</a>
<button type="submit" class="btn btn-deep-orange">Editar</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
然后在 web.php 中,我创建了以下路由:
Route::group(['middleware' => ['auth', 'isAdmin']], function () {
Route::get('/dashboard', function () {
return view('admin.dashboard');
});
Route::get('registered-user', 'Admin\RegisteredController@index');
Route::get('registered-empresa', 'Admin\EmpresaController@index');
Route::get('role-edit/{id}', 'Admin\RegisteredController@edit');
Route::put('role-update/{id}', 'Admin\RegisteredController@updaterole');
Route::post('save-empresa', 'Admin\EmpresaController@store');
Route::get('/edit-empresa/{id}', 'Admin\EmpresaController@edit');
Route::put('/empresa-update/{id}', 'Admin\EmpresaController@update');
});
如前所述,我消除了编辑模式并重定向到 empresa edit.blade.php 文件。
- 3 回答
- 0 关注
- 157 浏览
添加回答
举报