Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vishal_laravel's avatar

How can redirect to a page in laravel

I wants to make a list page and add page for list page my route function is

Route::get('admin/auctionlist','AdminController@showAuctionList');

and controller is

public function showAuctionList(){
        $auctions = DB::table('auctionitems')
                        ->leftjoin('campaigns','campaigns.id','=','auctionitems.campId')
                        ->select('auctionitems.*','campaigns.title')
                        ->get();
        return View::make('admin/auctionlist')->with('auction',$auctions);
    }

it works fine and my url is http://localhost/vishal/site/public/admin/auctionlist

And for my add page route is

Route::post('addAuction',function(){
    $obj = new AdminController() ;
    return $obj->addAuction();
});     

controller is

public function addAuction(){
        AuctionModel::addAuctions(Input::except(array('_token')));
         return $this->showAuctionList();       
    }   

It redirects to list page but url showing as http://localhost/vishal/site/public/addAuction Aucually i want to the url as http://localhost/vishal/site/public/admin/auctionlist how can i get it.?

0 likes
5 replies
bobbybouwmann's avatar

You just return the view to the same page. You need to redirect the user instead

public function addAuction(){
        AuctionModel::addAuctions(Input::except(array('_token')));
    
    return $this->redirect('/some-url');

    // Or
    return $this->redirect()->route('some-route-name');
}   
vishal_laravel's avatar

ERROR: exception 'BadMethodCallException' with message 'Method [redirect] does not exist.' in /var/www/html/vishal/site/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:268 getting an error like this .I'm using laravel 4.

thomaskim's avatar
Level 41

Using bobbybouwmann's example, for Laravel 4, you can use the Redirect facade to achieve this:

return Redirect::to('some-url');

// Or
return Redirect::route('some-route-name');
bobbybouwmann's avatar

Thank you for telling that you use Laravel 4... Would been nice if you had mentioned that!

Please or to participate in this conversation.