【发布时间】:2018-01-01 01:52:26
【问题描述】:
我有两个搜索表单,一个是主页,另一个是其他页面。主页搜索表单搜索建筑物,而另一个搜索在该页面中找到的办公室。
主页搜索表单在这里工作是代码
BuildingController.php
$search = \Request::get('search');
$buildings = Building::where('name','like','%'.$search.'%')->orderBy('id', 'asc')->paginate();
return view('buildings')->with('buildings', $buildings);
buildings.blade.php
{!! Form::open(['method'=> 'GET','url'=>'/','role'=>'search']) !!}
<div class="input-group col-xs-4 col-md-6" >
<input type="text" name="search" class="form-control" placeholder="Search...">
<span class="input-group-btn">
<button type="submit" class="btn btn-info btn-md">Search</i>
</button>
</span>
</div>
{!! Form::close()!!}
这是办公室的另一种搜索表单,每当我点击搜索时它都无法正常工作,它会将我重定向回主页
OfficeController.php
$searchoffice = \Request::get('searchoffice');
$offices = Office::where('name','like','%'.$searchoffice.'%')->get();
$data['building'] = $offices
return view('$offices',$data);
building.blade.php
{!! Form::open(['method'=> 'GET','url'=>'/','role'=>'$searchoffice']) !!}
<div class="input-group col-xs-4 col-md-6" >
<input type="text" name="searchoffice" class="form-control" placeholder="Search...">
<span class="input-group-btn">
<button type="submit" class="btn btn-info btn-md">Search</i>
</button>
</span>
</div>
{!! Form::close()!!}
路线
Route::get('/home', 'HomeController@index')->name('home');
Route::get('/', 'BuildingController@index')->name('index');
Route::get('building/{id}', 'PageController@show');
Route::get('buildings/create', 'BuildingController@create')->name('createbform')
Route::post('building/create/store', 'BuildingController@store')->name('createbuilding');
Route::get('building/{id}/edit', 'BuildingController@edit');
Route::post('building/{id}/edit', 'BuildingController@update')->name('editbuilding');
Route::get('building/{id}/delete', 'BuildingController@destroy');
Route::get('office/{id}', 'OfficeController@show')->name('officeMenu');
Route::get('building/{id}/offices/create', 'OfficeController@create')->name('createofficeform');
Route::post('building/{id}/offices/create/store', 'OfficeController@store')->name('createoffice');
Route::get('building/{id}/offices/edit', 'OfficeController@edit')->name('editofficeform');
Route::post('building/{id}/offices/edit', 'OfficeController@update')->name('editoffice');
Route::get('offices/{id}/delete', 'OfficeController@destroy')->name('deleteoffice');
【问题讨论】:
-
请显示相关路线。
-
@AlexeyMezenin 那里
-
我已经回答了原始问题和 cmets 中的其他几个问题,所以请接受我的回答。