{"action":"created","issue":{"url":"https://api.github.com/repos/cviebrock/eloquent-sluggable/issues/137","labels_url":"https://api.github.com/repos/cviebrock/eloquent-sluggable/issues/137/labels{/name}","comments_url":"https://api.github.com/repos/cviebrock/eloquent-sluggable/issues/137/comments","events_url":"https://api.github.com/repos/cviebrock/eloquent-sluggable/issues/137/events","html_url":"https://github.com/cviebrock/eloquent-sluggable/issues/137","id":77317022,"number":137,"title":"Slug including the primary key causes problems","user":{"login":"barryvanveen","id":8548677,"avatar_url":"https://avatars.githubusercontent.com/u/8548677?v=3","gravatar_id":"","url":"https://api.github.com/users/barryvanveen","html_url":"https://github.com/barryvanveen","followers_url":"https://api.github.com/users/barryvanveen/followers","following_url":"https://api.github.com/users/barryvanveen/following{/other_user}","gists_url":"https://api.github.com/users/barryvanveen/gists{/gist_id}","starred_url":"https://api.github.com/users/barryvanveen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barryvanveen/subscriptions","organizations_url":"https://api.github.com/users/barryvanveen/orgs","repos_url":"https://api.github.com/users/barryvanveen/repos","events_url":"https://api.github.com/users/barryvanveen/events{/privacy}","received_events_url":"https://api.github.com/users/barryvanveen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-17T14:07:24Z","updated_at":"2015-05-23T11:59:06Z","closed_at":null,"body":"I've been using the SluggableTrait for some time now and it really helped me a lot, thanks for the good work! Yesterday, after some changes I ran into a small problem when using the primary key in the slug.\r\n\r\nFor my blogposts I want to use slugs of the form [id]-[title-as-a-slug]. This way I can change my title and update the slug and still redirect people to the correct page. So, if my slug is like \"1-my-first-blog\" it can be updated to \"1-updated-my-first-blog\" without any problems because I identify the blogpost by its id and not by the entire slug. I thought that creates a nice descriptive url.\r\n\r\nThere is just one little problem. The initial slug is not created properly because when the `eloquent.saving*` event is fired a new blogpost doesn't have any id, that is only created when the database record is created. So instead of \"1-my-first-blog\" I get \"my-first-blog\" and only after updating the blogpost the slug is set at \"1-my-first-blogpost\".\r\n\r\nIs there any particular reason why eloquent-sluggable uses the `eloquent-saving*` event and not the `eloquent-saved*` event? Changing the event would allow anybody to use id's in their slugs without any problems. \r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/cviebrock/eloquent-sluggable/issues/comments/104885185","html_url":"https://github.com/cviebrock/eloquent-sluggable/issues/137#issuecomment-104885185","issue_url":"https://api.github.com/repos/cviebrock/eloquent-sluggable/issues/137","id":104885185,"user":{"login":"barryvanveen","id":8548677,"avatar_url":"https://avatars.githubusercontent.com/u/8548677?v=3","gravatar_id":"","url":"https://api.github.com/users/barryvanveen","html_url":"https://github.com/barryvanveen","followers_url":"https://api.github.com/users/barryvanveen/followers","following_url":"https://api.github.com/users/barryvanveen/following{/other_user}","gists_url":"https://api.github.com/users/barryvanveen/gists{/gist_id}","starred_url":"https://api.github.com/users/barryvanveen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barryvanveen/subscriptions","organizations_url":"https://api.github.com/users/barryvanveen/orgs","repos_url":"https://api.github.com/users/barryvanveen/repos","events_url":"https://api.github.com/users/barryvanveen/events{/privacy}","received_events_url":"https://api.github.com/users/barryvanveen/received_events","type":"User","site_admin":false},"created_at":"2015-05-23T11:59:06Z","updated_at":"2015-05-23T11:59:06Z","body":"Thanks for the suggestion, I don't know why I never thought of that before. It works perfectly and it makes for a much more elegant solution!"}}