search

Home  >  Q&A  >  body text

Create method in Laravel

$save['title']=$rv['title'];
$save['url']='http://pan.baidu.com';
Ukcont::create($save);

The above is my method of creating new data, using the Ukcont table.

The picture below shows the error message:

I’m a little confused, why is it ukconts? The model I created is also ukcont, and the data table is also ukcont. Ask for advice.

淡淡烟草味淡淡烟草味2765 days ago492

reply all(2)I'll reply

  • 世界只因有你

    世界只因有你2017-05-31 10:36:25

    Table name

    Note that we didn’t tell Eloquent which table to use for our Flight
    model. The default rule is that the plural of the model class name is used as the corresponding table name, unless another name is explicitly specified in the model class. So, in this case, Eloquent thinks the
    Flight model stores records in the flights table. You can also define the table attribute in the model to specify a custom table name:

    Reference: http://laravelacademy.org/pos...

    reply
    0
  • 黄舟

    黄舟2017-05-31 10:36:25

    Laravel is a very elegant framework. How elegant is it? Be elegant enough that your table names, by default, are the plural form of your models. So if you don't name it according to this, then you must specify the table name in the model.

    protected $table = 'ukcount';

    reply
    0
  • Cancelreply