[英]How to pass request object in laravel from one file to another file?
I have 3 files called RequestCriteria,GetAllDataTask,GetAllDataAction
.我有 3 个名为
RequestCriteria,GetAllDataTask,GetAllDataAction
文件。
RequestCriteria.php
public function __construct(Request $request)
{
$this->request = $request;
}
GetAllDataTask.php
public function run( $data)
{
$this->repository->pushCriteria(new RequestCriteria($data));
}
GetAllDataAction.php
public function run(Request $request){
$data=$request->all();
$result=Apiato::call("Books@GetAllDataTask",[$data]);
}
when i am passing $data in GetAllDataTask.php while calling the RequestCriteria it's throwing an error called The $data must be an Request object \\Illuminate\Http\\Request
,How to fix this issue please help me当我在调用 RequestCriteria 时在 GetAllDataTask.php 中传递 $data 时,它会抛出一个名为
The $data must be an Request object \\Illuminate\Http\\Request
的错误,如何解决此问题,请帮助我
In Action file it's already $request
is an Request class object so you have to update in RequestCriteria.php
.在 Action 文件中,它的
$request
已经是 Request class object 所以你必须在RequestCriteria.php
中更新。
public function __construct($newObj)
{
$this->request = $newObj;
}
i hope this will work...我希望这会奏效......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.