1 year ago

Something like @if in controllers

Posted 1 year ago by kordix

Can I use something like @if but in controllers, not in the views?

Here's concept: I have a language learning program. It just asks me for words, when i answer for one word it moves to another. I have a $next variable to set the next word, it depends from a few factors. If I want to use one category, its ->where('category'=$this->currentcategory , if I want to learn sentences its ->where('sentence'=$this->sentencesetting etc.

Now what I can do is writing multiple if's for every condition. Can't I just conditionally add some piece of code?

Please sign in or create an account to participate in this conversation.