Laravel - Getting Started - Primary Keys

Eloquent will also assume that each model's corresponding database table has a primary key column named id. If necessary, you may define a protected $primaryKey property on your model to specify a different column that serves as your model's primary key:

    
    

In addition, Eloquent assumes that the primary key is an incrementing integer value, which means that Eloquent will automatically cast the primary key to an integer. If you wish to use a non-incrementing or a non-numeric primary key you must define a public $incrementing property on your model that is set to false:

    
    

If your model's primary key is not an integer, you should define a protected $keyType property on your model. This property should have a value of string:

    
    

© 2020-2021 | Powered by shifu