Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pass Request to method in Laravel

I want to pass the request parameter to the method, but i fail every time. I am beginner in PHP.

`

public function changeModel(Request $request)
    {
        $u1 = $request->U;
        
        Schema::table('planspieldatas', function (Blueprint $table) {
            $table->renameColumn('U1', $u1);
    });
    
        Artisan::call('migrate');
        return redirect('/pssettings')->with('success-upload', 'Daten für Markt'.$u1);
    }

`

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I am not able to pass the $u1 variable to the Schema::table method. Is there any option to change the coloumn names in sql from the front end.

I am not able to pass the $u1 variable to the Schema::table method. Is there any option to change the coloumn names in sql from the front end.

>Solution :

You are using Closure method so you need to use use() method to pass variables like

Schema::table('planspieldatas', function (Blueprint $table) use ($u1) {
        $table->renameColumn('U1', $u1);
});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading