fbc's avatar
Level 2

Blade file best practices?

I've heard you are supposed to do all your logic in the controller and minimal in your blade. I have sort of a conundrum as I have two different bill types that use the same model and DBtable but different need to be displayed differently with the SHOW function.

Right now I have a whole bunch of IF statements to include or exclude the things I need to show depending on the type of bill it is. So you can imagine how complicated that blade file is.

Should I be making separate SHOW blades for each type, directing the function to the separate show files and making includes for those snippets they have in common?

0 likes
1 reply
click's avatar
click
Best Answer
Level 35

There is no right and wrong option. But if your blade file becomes to long / too complicated to read I would indeed split it up in two files and use includes or blade components to build the files.

1 like

Please or to participate in this conversation.