簡體   English   中英

Laravel 5.2來自其他沒有JS的控制器的動作請求

[英]Laravel 5.2 Request to action from other controller without 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());
}

請求通過,但Request :: all()為空[]

dd在$ 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"
}

我需要在Category.php (Request :: all())上以$_POST獲取request->parameters

提交表單時,如何導致另一個組件的動作並傳遞其參數?

這就是我從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'));

回答:

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

之前

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM