0

I have a method with a lot of code

public function createNewObject(Request $request) { // Code... } 

There is another method that I plan to call, but how to pass it to the createNewObject method as a Request argument?

public function deleteAndCreateObject() { $this->createNewObject(???); } 

1 Answer 1

1

Just type-hint it in your deleteAndCreateObject() method.

class YourController { public function createNewObject(Request $request) { // Code... } public function deleteAndCreateObject(Request $request) { $this->createNewObject($request); } } 

If that—for some reason—doesn't work for you, you can always use request():

class YourController { public function createNewObject() { $request = request(); // Code... } public function deleteAndCreateObject() { $this->createNewObject(); } } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.