{"action":"created","issue":{"url":"https://api.github.com/repos/caffeinated/menus/issues/50","labels_url":"https://api.github.com/repos/caffeinated/menus/issues/50/labels{/name}","comments_url":"https://api.github.com/repos/caffeinated/menus/issues/50/comments","events_url":"https://api.github.com/repos/caffeinated/menus/issues/50/events","html_url":"https://github.com/caffeinated/menus/issues/50","id":93995542,"number":50,"title":"Placement of the menu code and the alternatives.","user":{"login":"fredrkr","id":351744,"avatar_url":"https://avatars.githubusercontent.com/u/351744?v=3","gravatar_id":"","url":"https://api.github.com/users/fredrkr","html_url":"https://github.com/fredrkr","followers_url":"https://api.github.com/users/fredrkr/followers","following_url":"https://api.github.com/users/fredrkr/following{/other_user}","gists_url":"https://api.github.com/users/fredrkr/gists{/gist_id}","starred_url":"https://api.github.com/users/fredrkr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredrkr/subscriptions","organizations_url":"https://api.github.com/users/fredrkr/orgs","repos_url":"https://api.github.com/users/fredrkr/repos","events_url":"https://api.github.com/users/fredrkr/events{/privacy}","received_events_url":"https://api.github.com/users/fredrkr/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/caffeinated/menus/labels/documentation","name":"documentation","color":"333333"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-09T09:00:35Z","updated_at":"2015-07-23T06:33:24Z","closed_at":null,"body":"I appreciate that you suggest a home for the menu-specific code in ones app. However, I'm still a bit perplexed. \r\n\r\nYour wiki's quick-start section states that it's best, by convention, to place the code in a service provider. That is all well and good... Until you want to use the filter-method to filter out menu-items based on e.g. the role of the logged in user. Session data is unavailable from a provider, so you can't really do that without a workaround of some sort. At least this was the case, last time I looked into it.\r\n\r\nThe \"Basics of Menus\"-section contradicts the quick-start section by stating that the ideal place for the menu-code is a middleware. I find that a middleware is more appropriate, but still not without some minor problems. For instance, if you define the menu-middleware as global and your app has some pages without the menu, like a login-page, your package will still attempt to build the menu. Basically, the **route** decides if the menu is created or not.\r\n\r\nA third option, not mentioned in the docs, is a dedicated view composer. First, you need a provider to bind views and composers together. This means you get to decide, in a clean way, when a given view composer should be used. In the composer itself, you also have access to the currently logged in user, which is nice. More importantly, the *view* is the deciding factor for whether the menu is created or not, giving you much more granular control than the middleware approach.\r\n\r\nHow about a dedicated section in your wiki that talks about the alternatives? Laravel itself is all about the freedom to choose for oneself, after all :-)\r\n\r\nEdit: Wording and typos."},"comment":{"url":"https://api.github.com/repos/caffeinated/menus/issues/comments/123994898","html_url":"https://github.com/caffeinated/menus/issues/50#issuecomment-123994898","issue_url":"https://api.github.com/repos/caffeinated/menus/issues/50","id":123994898,"user":{"login":"hcancelik","id":5788410,"avatar_url":"https://avatars.githubusercontent.com/u/5788410?v=3","gravatar_id":"","url":"https://api.github.com/users/hcancelik","html_url":"https://github.com/hcancelik","followers_url":"https://api.github.com/users/hcancelik/followers","following_url":"https://api.github.com/users/hcancelik/following{/other_user}","gists_url":"https://api.github.com/users/hcancelik/gists{/gist_id}","starred_url":"https://api.github.com/users/hcancelik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hcancelik/subscriptions","organizations_url":"https://api.github.com/users/hcancelik/orgs","repos_url":"https://api.github.com/users/hcancelik/repos","events_url":"https://api.github.com/users/hcancelik/events{/privacy}","received_events_url":"https://api.github.com/users/hcancelik/received_events","type":"User","site_admin":false},"created_at":"2015-07-23T06:33:24Z","updated_at":"2015-07-23T06:33:24Z","body":"@fredrkr you can also define a route middleware and use it for certain routes. This way you can decide which pages you want to build the menu. "}}