I am writing a website backend configuration page. There is only one data table for this data, namely ID=1 and no id=2. Updated data modifications are all covered in id=1
But how to save the following code to ID=1?
public function edit()
{
$configs = new Configs();
//这个ID传输 在模版是<input type="hidden" name="id" value="1" />
$configs->id = Request::input('id');
$configs->web_name = Request::input('web_name');
$configs->web_add = Request::input('web_add');
$configs->web_email = Request::input('web_email');
$configs->web_copy = Request::input('web_copy');
$configs->web_keywords = Request::input('web_keywords');
$configs->web_description = Request::input('web_description');
//问题在这里了,如何直接保存到数据库ID1里呢 这样写好像不对
$configs = Configs::find(1);
$configs->save();
return redirect('/admin/config');
}
will
$configs=new Configs();
改为$configs=Configs::find(1);
Then comment out the following
$configs = Configs::find(1)
...or the second method: