how to extend a class from a different controller in laravel code example
Example: extend custom controller in laravel
public function error($message = null, Exception $ex) { return response()->json([ 'message' => $message ?? 'an error occurred', 'exception' => $ex ], 500);}