How to use a variable from a function in another function in laravel - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Sunday, November 26, 2023

How to use a variable from a function in another function in laravel

I need to use an variable to make a query in other function. How i can do this?

     public function getestados($nick)
     {
        $nivel = DB::table('locais')
        ->where('nick', $nick)
        ->get('nivel');

        return $nivel->toJson(JSON_PRETTY_PRINT);
     }

     public function elevar($nivel) {

        $novonivel = DB::table('niveis')
        ->where('cond', $nivel) // previous variable
        ->get();

        return response()->json([$novonivel]);

     }


source https://stackoverflow.com/questions/77549046/how-to-use-a-variable-from-a-function-in-another-function-in-laravel

No comments:

Post a Comment