Expose an object (based on the request) for every application

0

Oops, I do not know if it's possible to do what I want, but come on:

I have an api in lumen which basically read a specific header from the request and parse it into a YAML file and transforms it into an array, but as I use it in several different controllers and classes I've done a function that gets this header and returns the array, but I'm having to repeat this in every controller / class, what I want is:

Turn this "function" into something global so I can call any method / class type like this:

public function verifyemail(Cliente $cliente) {
  $email = $cliente->email
}

Where the client is the function that returns the array.

Type as app () that I can use anywhere:

app()->environment() == 'development' 

I think I was clear, if not, ask me.

    
asked by anonymous 18.09.2018 / 22:06

1 answer

0

I think that in this case the best solution is to put this method in the file Controller.php and then all other controllers of your application that extend this class can use this method normally.

    
10.10.2018 / 02:16