Laravel - What is the effective or logical design pattern to handle if / else in a view

design-patterns, laravel, php

Solution

Handle this logic outside the view and have the result of the logic set a variable for the view with the appropriate result. As for avoiding the 'if-tree' the strategy pattern may come in useful depending on the situation.

Problem

Currently i have a pretty big project, where i need to store different data for different type of users. I need to store body details for models. The problem what i am stuck with is that, female will have different body information than male, and agencies, photographers dont need body information, and the users are in groups ``` group 3 - Model group 4 - Agency group 5 - photographer ``` In my views i am currently doing this ``` if ($group == 3 && $gender == 2) { // load female body information (lot of details) } elseif ($group == 3 && $gender == 1) { // load male body information (lot of details) } else { // load just work explerience & company info } ``` Is store the users information broken in 3 tables ``` users . login information users_details - users details, like first last name gender ect users_body - Body information for models both female / male ``` So why i am asking for a hint for a more effective way because i will need this type of information shown on 3 different pages, and i think it will get messy and will result lot of code duplications If someone could give me a hint on any advice would be happy thank you

Original source