I'm just wondering why the schema builder in laravel automatically convert all camel case to lower case in table naming
E.g
Schema::create('myTable', function(Blueprint $table)
{
....
});
It creates tablename: mytable
Why is that? Is that a convention of laravel? I don't see it in the laravel docs Schema Builder page.
Thanks
It's a common practice to use snake case in table names and field names as well and it's not only related to laravel but most people follow this convention. In Laravel
's old (4x) documentation, it's been mentioned that:
Note that we did not tell Eloquent which table to use for our User model. The lower-case, plural name of the class will be used as the table name unless another name is explicitly specified. So, in this case, Eloquent will assume the User model stores records in the users table. You may specify a custom table by defining a table property on your model:
class User extends Eloquent {
protected $table = 'my_users';
}
So, yes, Laravel
uses strtolower
function in many places and probably this is better to follow the common convention and it's (my_table
) known as snake case
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With