0
嘿,朋友我正在創建一個簡單的模式來向我顯示提供者的數據,並且老實說我花了很多錢;有人能幫我一把嗎?Modal with Laravel中的控制器
模態:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
aria-labelledby="myModal">
<div class="modal-dialog"
role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModal">Detalle del Proveedor: </h4>
</div>
<div class="modal-body">
<div class="table-responsive">
<table class="table table-stripped table-bordered table-hover" id="table-detalle-proveedores">
<thead>
<tr>
<th>Nombre</th>
<th>Apellido</th>
<th>Telefono</th>
<th>Email</th>
<th>Dirección</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
</div>
</div>
</div>
</div>
模態的鈕
路線
Route::post('admin/proveedores/item', [
'as' => 'admin.proveedores.item',
'uses' => '[email protected]']);
控制器的功能
public function item(Request $request)
{
$items = Proveedores::select($request->id);
return json_encode($items);
}
我測試的是一個和其他人,但我得到它顯示我在控制檯一個空對象
find和findorfail和有什麼區別? – basosneo
@basosneo如果find'不存在,find'將返回'null'。 'findOrFail()'會拋出一個異常,最終會變成404響應。 https://laravel.com/docs/5.3/eloquent#retrieving-single-models –
因爲我使用'find'工作,因爲'findorfail'不工作 – basosneo