2016-01-13 60 views
1

需要從嚮導向控制器類別發送請求。Laravel 5.2請求從其他沒有js的控制器採取行動

嚮導動作:

$request = Request::create('/admin/category', 'POST', $this->prepare_category($row->toArray())); 
Route::dispatch($request); 

類別動作:

public function store(Request $request, ContentPlugins $plugins) 
{ 
    dd(Request::all()); 
} 

該請求通過,但支持::所有()是在$請求空[]

DD:

Request {#1922 ▼ 
    #json: null 
    #userResolver: null 
    #routeResolver: null 
    +attributes: ParameterBag {#1859 ▼ 
    #parameters: [] 
    } 
    +request: ParameterBag {#1726 ▼ 
    #parameters: array:11 [▼ 
     "title" => "Фотосувениры" 
     "level" => "0" 
     "description" => null 
     "cost" => null 
     "what" => null 
     "type" => "catalog" 
     "parent" => 0 
     "url" => "fotosuveniry-0-0" 
     "sitemap" => 1 
     "active" => 1 
     "position" => 0 
    ] 
    } 
    +query: ParameterBag {#1920 ▶} 
    +server: ServerBag {#1679 ▶} 
    +files: FileBag {#1728 ▶} 
    +cookies: ParameterBag {#1727 ▶} 
    +headers: HeaderBag {#1886 ▶} 
    #content: null 
    #languages: null 
    #charsets: null 
    #encodings: null 
    #acceptableContentTypes: null 
    #pathInfo: null 
    #requestUri: null 
    #baseUrl: null 
    #basePath: null 
    #method: null 
    #format: null 
    #session: null 
    #locale: null 
    #defaultLocale: "en" 
} 

我需要得到request->parameters$_POSTCategory.php(支持::所有())

如何引起另一個組件的動作,並通過作爲提交表單時,它的參數?

這就是我從Kohana的http://kohanaframework.org/3.3/guide/kohana/requests#external-requests需要

它使用POST

$request = Request::factory('http://example.com/post_api')- >method(Request::POST)->post(array('foo' => 'bar', 'bar' => 'baz')); 

回答

1

答:

Input::merge($this->prepare_category($row->toArray())); 

$request = Request::create('/admin/category', 'POST'); 
Route::dispatch($request);