Laravel5.3 控制器存储数据不成功
Model类:
class CenterSetup extends Model
{
protected $table = 'Centersetup';
}
控制器:
public function Default(){
$_centersetup=CenterSetup::all();
foreach ($_centersetup as $a) {
if ($a->Clientid=='')
{
$new=new CenterSetup;
$new->Clientid=Uuid::generate();
$new->Centeraddr='http://center.hsppl.me/License';
$new->Softwareversion = env('Softwareversion', '1.0.0.0');
$new->Clientname =env('COMPANYNAME', '某某某有限公司');
if ($new->save()){
return '首次创建成功';
var_dump($new);
}else
{
return '首次创建失败!';
}
}
}
return view('Admin.CenterSetup');
执行过程只返回视图,数据表还是空的。
请教各位大神如何解决~
1 Comment
其中控制器的引用为:
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\CenterSetup;
use Webpatser\Uuid\Uuid;