Laravel 5.2请求其他控制器在没有js的情况下采取行动

时间:2016-01-13 07:32:56

标签: php laravel post laravel-5 request

需要从向导发送请求到控制器类别。

向导动作:

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

分类行动:

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

请求通过,但Request :: all()为空[]

<$> dd on $ request:

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"
}

我需要在{strong> Category.php (Request :: all())

上将request->parameters作为$_POST

如何引起其他组件的操作并在提交表单时传递参数?

这就是我需要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 个答案:

答案 0 :(得分:1)

答案:

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

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