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);
}
`
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.
CodePudding user response:
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);
});