Answer the question
In order to leave comments, you need to log in
Code improvement. How to improve checks?
There is a page where user data is displayed. There are 2 avatar pictures and a background, I check for the presence of a path in the database, if there is a path, then it shows a picture; if not, then the default picture, but for each picture you have to do the same checks, and it looks terrible. How can this be improved?
Answer the question
In order to leave comments, you need to log in
We write a method that returns true or false and checks for the presence of any image, depending on the passed key. We write a getter that returns a url, in which the condition depends on the execution of the first method. And it's all in the user object. Then just$user->avatar
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question