Reading Time: < 1 minute
getKey()
method Gets the value of the model’s primary key.
To get the id of the current model in laravel, use the getKey method or just use the primary key column name as the property name from the model object.
//Use the primary key column name as the object property:
$modelObject->primary_key_col_name;
//Inbuilt Eloquent method to find primary key:
$modelObject->getKey();