jeudi 3 décembre 2015

How to pass Request object from route in Laravel??

Following is my routes where I am calling my Controller directly in route. How can I pass Request $request to my getBlog Function.. Or is there any way to directly get $request object in my getblog function of controller ???

$artObj = App::make('App\Http\Controllers\Front\ArticleController'); 
return $artObj->getBlog($id);

Code in Routes:

Route::get('/{slug}', function($slug) {
         // Get Id and Type depending on url 
          $resultarray = App\Model\UrlAlias::getTypefromUrl($slug);
          if(!empty($resultarray)){
              if($resultarray[0]['type'] == 'article'){
                $id = $resultarray[0]['ref_id'] ;
                $artObj = App::make('App\Http\Controllers\Front\ArticleController');
                 return $artObj->getBlog($id);
            } 
              else {
                    return Response::view("errors.404", $msg, 400);
             }
         }else {
                return Response::view("errors.404", array(), 400);
          }

        });



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire