我已經寫了一些代碼來檢索用戶訪問url時數據庫中的一些數據。 例如,當有人訪問這個:在表單動作中使用表單輸入值,Laravel 5.4
http://localhost:8000/home/foo
他會看到類似:
foome
fooyou
foohim
fooher
現在,我要對它進行配置,使HTML表單在我的home.blade.php頁。
當有人以這種簡單的形式輸入查詢時,他應該像上面那樣重定向到一個url。例如,假設他將「foo1」輸入到此表單中。他應該去:
http://localhost:8000/home/foo1
,看到了相同的值以上:
foo1me
foo1you
foo1him
foo1her
所以,我在我的控制器中使用這樣的:
class DomainGeneratorController extends Controller
{
public function keywordreturn()
{
return view('home');
}
public function userkeyword(Request $inputtedkeyword, $id)
{
$blog = DB::table('keywords')->pluck('blog');
$hosting = DB::table('keywords')->pluck('hosting');
return view('home', ['inputtedkeyword' => $id, 'category' => $blog]);
}
}
,這裏是我的路線:
Route::get('/', '[email protected]');
Route::auth();
Route::get('/home', '[email protected]');
Route::resource('home/{id}', '[email protected]');
最後,這裏是home.bla de.php:
<div class="panel-body">
@if(isset($category))
<table>
<tbody>
<tr>
<td>Keyword</td>
<td>.COM</td>
<td>.NET</td>
<td>.ORG</td>
</tr>
@foreach($category as $item)
<tr>
<td>{{ $inputtedkeyword }}{{ $item }}</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>{{ $item }}{{ $inputtedkeyword }}</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
@endforeach
</tbody>
</table>
@else
<p>Enter your own keyword</p>
<form method="POST" id="domaininput"
action="{{ action('[email protected]', $id = Request::get("find")) }}">
<div id="check" class="input-group margin-bottom-sm">
<input class="form-control" type="text" name="find" placeholder="Search">
<button type="submit">
<div id="search" class="input-group-addon">
<i class="fa fa-search"></i>
</div>
</button>
</div>
</form>
@endif
</div>
我在哪裏做錯了?請幫幫我。謝謝。
什麼問題? – Jackowski