I've created a seperate (mongo) database to save logs to each incoming api request.
private function log($type, $object){
Logevent::create([
'type' => [THE CALLED API METHODS NAME, E.G. INDEX],
'user_id' => [ID OF AUTHENTICATED REQUESTER],
'description' => [SHORT DESCRIPTION OF REQUEST],
'table' => [TABLE NAME OF PROCESSED OBJECT],
'table_id' => [ID OF OBJECT IN TABLE];
}
In the current version I'm calling the above method in every single method of each controller. I've tried After-Middlewares but could not pass the params $type and the processed $object to it (in order to determine to which entity the request is related to and which request method is called).
Is there a more elegant (and "official") way to handle this issue in Laravel 5.7?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire