【问题标题】:Laravel 5.2 Request to action from other controller without jsLaravel 5.2 请求来自其他控制器的操作,没有 js
【发布时间】:2016-01-13 07:32:56
【问题描述】:

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

向导操作:

$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()为空[]

在 $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->parameters 设为 $_POST (Request::all())

如何触发另一个组件的动作,并像提交表单时一样传递参数?

这就是我需要 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'));

【问题讨论】:

    标签: php laravel post laravel-5 request


    【解决方案1】:

    答案:

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

    之前

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

    【讨论】:

      猜你喜欢
      • 2012-03-04
      • 2013-11-29
      • 1970-01-01
      • 2019-12-29
      • 2020-08-06
      • 2016-10-24
      • 1970-01-01
      • 2017-02-18
      • 1970-01-01
      相关资源
      最近更新 更多