Add hash for url in Laravel using pagination

My route:

Route::get('/app/search', ['as' => 'search', 'uses' => 'AppController@getSearch']);

      

My controller:

public function getSearch()
{        
    $searchTerm = Input::get('s');
    $locs = Loc::whereRaw('match(title, description) against(? in boolean mode)', [$searchTerm])
        ->paginate(10); 
    $locs->getFactory()->setViewName('pagination::slider');        
    $locs->appends(['s' => $searchTerm]);
    $this->layout->with('title', 'Search: ' . $searchTerm);
    $this->layout->main = View::make('home')
        ->nest('content', 'index', ($locs->isEmpty()) ? ['notFound' => true] : compact('locs'));
}

      

I get the url: "www.example.com/app/search?s=search+term"

I would like to get: "www.example.com/app/search?s=search+term#result" to go directly to the result item.

I tried using $locs->fragment('result')->links();

both in controller and view, but nothing changed.

People are asking for more information to show where the url is generated, but the problem is I don't know that. Neither Route, nor Controller, nor View responds to this.

What's strange is that I can't figure out how the url is generated, I thought that:

$locs->appends(['s' => $searchTerm]);

responsible for this, but even if I remove this line nothing changes in the url. So I'm really stuck on this, the laravel docs doesn't help and I can't find any docs or help on the internet.

+3
url php pagination laravel


source to share


No one has answered this question yet

Check out similar questions:

4622
What is the maximum URL length in different browsers?
4193
What is the difference between URI, URL and URN?
3419
How do I change the URI (URL) for a remote Git repository?
2853
Get the current url using JavaScript?
2366
Encode url in JavaScript?
2170
How can I change the url without reloading the page?
1690
Get current url using jQuery?
1168
Path.Combine for URLs?
978
Get full url in PHP
0
Laravel 5 Paging search route



All Articles
Loading...
X
Show
Funny
Dev
Pics