{"action":"created","issue":{"url":"https://api.github.com/repos/cviebrock/eloquent-sluggable/issues/286","repository_url":"https://api.github.com/repos/cviebrock/eloquent-sluggable","labels_url":"https://api.github.com/repos/cviebrock/eloquent-sluggable/issues/286/labels{/name}","comments_url":"https://api.github.com/repos/cviebrock/eloquent-sluggable/issues/286/comments","events_url":"https://api.github.com/repos/cviebrock/eloquent-sluggable/issues/286/events","html_url":"https://github.com/cviebrock/eloquent-sluggable/issues/286","id":162705536,"number":286,"title":"Use alternate field if source would generate an empty slug","user":{"login":"rickselby","id":1564517,"avatar_url":"https://avatars.githubusercontent.com/u/1564517?v=3","gravatar_id":"","url":"https://api.github.com/users/rickselby","html_url":"https://github.com/rickselby","followers_url":"https://api.github.com/users/rickselby/followers","following_url":"https://api.github.com/users/rickselby/following{/other_user}","gists_url":"https://api.github.com/users/rickselby/gists{/gist_id}","starred_url":"https://api.github.com/users/rickselby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rickselby/subscriptions","organizations_url":"https://api.github.com/users/rickselby/orgs","repos_url":"https://api.github.com/users/rickselby/repos","events_url":"https://api.github.com/users/rickselby/events{/privacy}","received_events_url":"https://api.github.com/users/rickselby/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-06-28T14:50:48Z","updated_at":"2016-07-15T15:29:50Z","closed_at":null,"body":"I've got an odd case - I'm pulling in user names from an external source. One of them comes through as '??', which slugs to an empty string. In the case of empty names, I'm using the model id as the source instead. In this case, though, the name itself is not empty.\r\n\r\nI tried the following:\r\n\r\n```\r\n    public function sluggable()\r\n    {\r\n        // The name might generate an empty slug; so use the ID if this is the case\r\n        $possibleSlug = SlugService::createSlug(self::class, 'slug', $this->name);\r\n        return [\r\n            'slug' => [\r\n                'source' => $possibleSlug ? 'name' : 'id',\r\n            ]\r\n        ];\r\n    }\r\n```\r\n\r\nbut this results in an infinite loop, as trying to generate the slug calls sluggable()...\r\n\r\nIs there a way to 'preview' the slug (even if it bypassed the valid / unique checks)?"},"comment":{"url":"https://api.github.com/repos/cviebrock/eloquent-sluggable/issues/comments/232984741","html_url":"https://github.com/cviebrock/eloquent-sluggable/issues/286#issuecomment-232984741","issue_url":"https://api.github.com/repos/cviebrock/eloquent-sluggable/issues/286","id":232984741,"user":{"login":"cviebrock","id":166810,"avatar_url":"https://avatars.githubusercontent.com/u/166810?v=3","gravatar_id":"","url":"https://api.github.com/users/cviebrock","html_url":"https://github.com/cviebrock","followers_url":"https://api.github.com/users/cviebrock/followers","following_url":"https://api.github.com/users/cviebrock/following{/other_user}","gists_url":"https://api.github.com/users/cviebrock/gists{/gist_id}","starred_url":"https://api.github.com/users/cviebrock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cviebrock/subscriptions","organizations_url":"https://api.github.com/users/cviebrock/orgs","repos_url":"https://api.github.com/users/cviebrock/repos","events_url":"https://api.github.com/users/cviebrock/events{/privacy}","received_events_url":"https://api.github.com/users/cviebrock/received_events","type":"User","site_admin":false},"created_at":"2016-07-15T15:29:50Z","updated_at":"2016-07-15T15:29:50Z","body":"Ah ... I get it.  Yeah, that isn't going to work.\r\n\r\nI think you'd need to use some other logic, other than a call to `createSlug` to test what the slug will be.  Unless you're doing something fancy with the slug engine, maybe a simple regex match would work?"}}
{"actor":{"display_login":"cviebrock"}}