0
如何将$i
变量传递给此函数?Laravel:将变量传递给Schema :: create
$i = 0;
foreach(request('nazwa') as $n){
$nr = new Schemat;
$nr->specjalizacja_id = $s->id;
$nr->nazwa=$n;
$nr->typ=request('typ')[$i];
// $nr->save();
$i++;
}
$i = $i-1;
Schema::connection('mysql')->create($s->nazwa, function($table){
$table->increments('id');
$table->integer('pacjent_id');
$table->integer('wizyta_id');
for($j=$i; $j>=0; $j--){ //**Undefined variable: i ERROR**
if(request('typ')[$j] == 0){
$table->integer(request('nazwa')[$j]);
} elseif(request('typ')[$j] == 1){
$table->text(request('nazwa')[$j]);
} else {
$table->text(request('nazwa')[$j]);
}
}
$table->timestamps();
});
这就像一个魅力。延迟后会接受你的回答 – Ethris
很酷。另外看看我的代码格式 - 它是PSR2,它非常有用。 :) –
会检查出来 – Ethris