简体   繁体   中英

Laravel 5.2 Request to action from other controller without js

Need send request to controller Category from Wizard.

Wizard action:

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

Category action:

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

The request passes but Request::all() is empty []

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

I need to get request->parameters as $_POST on Category.php (Request::all())

How to cause the action of another component and pass it parameters as when submitting the form?

That's what I need from Kohana http://kohanaframework.org/3.3/guide/kohana/requests#external-requests

This uses POST

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

Answer:

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

before

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM