Home > Mobile >  How to pass request object in laravel from one file to another file?
How to pass request object in laravel from one file to another file?

Time:11-18

I have 3 files called 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

CodePudding user response:

In Action file it's already $request is an Request class object so you have to update in RequestCriteria.php.

public function __construct($newObj)
    {
        
        $this->request = $newObj;
    }

i hope this will work...

  • Related