I've written some code to retrieve some data from database when a user visits a url. For example, When someone visits this :
http://localhost:8000/home/foo
He will see something like :
foome
fooyou
foohim
fooher
Now, I want to configure it and make an html form in my home.blade.php page.
When someone enters a query in this simple form, He should be redirected to a url just like above. For example, Let's say that he enters "foo1" into this form. He should goes to :
http://localhost:8000/home/foo1
and see the same values as above :
foo1me
foo1you
foo1him
foo1her
So, I've used this in my controller :
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]);
}
}
and here is my routes :
Route::get('/', 'DomainGeneratorController@keywordreturn');
Route::auth();
Route::get('/home', 'DomainGeneratorController@keywordreturn');
Route::resource('home/{id}', 'DomainGeneratorController@userkeyword');
Finally, Here is home.blade.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></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
@endforeach
</tbody>
</table>
@else
<p>Enter your own keyword</p>
<form method="POST" id="domaininput" action="">
<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>
Where am I doing wrong? Please help me. Thanks.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lc326J
via IFTTT
Aucun commentaire:
Enregistrer un commentaire