When I create a model it returns a model with id set to 0
$key = Key::create(array(
'id' => 'someKey',
'valid_till' => new DateTime('now +2hours'),
'user_id' => 1
));
var_dump($key->id); // int(0)
Note that the id-field is not auto increnment but primary. Furtermore id is a string in the database and should never be int
The Model:
class Key extends Eloquent{
protected $table = 'keys';
protected $guarded = [];
}
The Schema
$table->string('id')->primary();
$table->dateTime('valid_till');
$table->timestamps();
$table->integer('user_id');
I'm using laravel 4.2.2
The Schemale
I do not think it means what you think it means.
lol - I have no Idea how a wrong written "Schema" could transform to this :D. I will change it^^
you need to set the auto incrementing property on your model to false
.
Most helpful comment
you need to set the auto incrementing property on your model to
false
.