Support the ongoing development of Laravel.io →
Eloquent Forms
Last updated 2 years ago.
0

Anyone can help ? at least please tell how to get the value of 'keyword' that user entered from view ??

<button class="submit" type="submit" onclick="location.href='{{ action('CompanyController@listCompany') }}'"> Search</button>

thanks!

Last updated 2 years ago.
0

What I do:

if(isset($_REQUEST['t1']))
        {
            $t1 = $_REQUEST['t1'];
        }
        else
        {
            $t1 = "";
        }
        $ownersearch = $t1;
        $ownersearch = $ownersearch . "%";
        //$ownersearch = "j";
        //$ownersearch = $ownersearch . "%";
        //
        $data['owners'] = DB::table('powners')
                        ->where('oname', 'like', $ownersearch)
                        ->orderBy('oname', 'asc')
                        ->Paginate(5);
        $data['osearch'] = $t1;  //needs passing each time for querystring/pagination

Then pass to view like:

return View::make('owner/pownerlist')->with('data', $data['owners'])->with('data2', $data['osearch']);

Of course intial search comes from a search form with whatever parameters need passed, like searchby. These params are added as needed in your application.

Probably a better way, but this is what I do. Also you can change $_REQUEST to $_POST.

Last updated 2 years ago.
0

Thanks jimgwhit, but i still cant get what i want, the $data['owners'] is same with $companys right ?

and in my controller i return View::make('company.listcompany', compact('companys','sortby', 'order')) ; like that, means i already pass the companys to view ?

i not und:
->with('data2', $data['osearch'] whats means ? and $data['osearch'] = $t1; whats osearch represent ?

thanks again

Last updated 2 years ago.
0
return View::make('owner/pownerlist')->with('data', $data['owners'])->with('data2', $data['osearch']);

'data', $data['owners'] is the resultset, and 'data2', $data['osearch'] and extras for query string/pagination read and watch video on pagination and passing extra info. view (didn't use blade, but you can convert all to blade, same idea):

<body>
<div>
owners
<form method="get" action="owners">
<label>sch</label><input type="text" name="t1" value=""> <input type="submit" name="submit" value="Search">       
</form>
</div>
    
    
    
<div style="margin-left: 20px; margin-right: auto; width: 800px; border:solid red; display:block;">    
    <table id="myTable">   
<thead style="background-color:lightblue"> 
<tr>
<th>ownerid</th>
<th>oname</th>
</tr>
</thead>

<?php
echo "<br>";

foreach ($data as $owner){
    //echo $owner['oname'];//works with ORM also
    //echo $owner->oname; //use with database and querybuilder and ORM
    echo "<tr>";
    echo "<td>"."<a href=\"\" >".$owner->ownerid."</a>"."</td>";
    echo "<td>"."<a>".$owner->oname."</a>"."</td>";
    echo "</tr>";

    
    
}
echo "</table>";
echo "</div>";
//echo $data->links();
echo '<br>';
//echo $users->appends(array('sort' => 'votes'))->links();




?>
    <!--<div style="clear:both; "></div>-->
    
    <div class="pagination" style="margin-left: 20px; margin-right: auto; width: 800px; border:solid red; display:  block;">
     
  <?php echo $data->appends(array('t1' => $data2))->links(); ?> ////t1 added to links read about pagination
    </div>
    
</body>
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

claratan claratan Joined 30 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.