Skip to content

How to Create Laravel Eloquent model without a primary key ?

Last updated on March 28, 2015

This post about Creating Laravel Eloquent model without a primary key,By default laravel will take primary key as ID, we can override this by protected $primaryKey = ‘something’;, but in order to turn of this we need to set it as shown below

    /**
     * primaryKey 
     * 
     * @var integer
     * @access protected
     */
    protected $primaryKey = null;

    /**
     * Indicates if the IDs are auto-incrementing.
     *
     * @var bool
     */
    public $incrementing = false;

That’s pretty much it. Leave a comment below if you have questions leave a comment

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments