在laravel中添加列时定义的变量

问题描述 投票:0回答:1
$save=$data->save();

if ($save) {
   Schema::table('users', function($table) {
      $table->string($data->id);
   });
   return back()->withInput()->with('message','Carrier Created Successfully');
}

И在表中保存的数据很少,想要在用户表中添加具有该数据的ID的列但出现错误:

未定义变量$ data

高亮显示的行是:

$table->string($data->id);
php laravel alter-table laravel-7.x
1个回答
0
投票

您需要使用use来使用从一个功能到另一个功能的其他变量

© www.soinside.com 2019 - 2024. All rights reserved.