laravel model string primary key 1

laravel model string primary key

class UserVerification extends Model
{
    protected $primaryKey = 'your_key_name'; // or null

    public $incrementing = false;

    // In Laravel 6.0+ make sure to also set $keyType
    protected $keyType = 'string';
}

Here is what the above code is Doing:
1. We are setting the primary key to be a string instead of an integer.
2. We are telling Laravel that the primary key is not auto-incrementing.
3. We are telling Laravel that the primary key is a string.

Similar Posts