My concern:
if ($case=='private') {
$langtitle = 'title';
}
else {
$langtitle='title_gov';
}
if it is Government (falls under else case above) I want to select, 'title'
as well as 'title_gov'
with Select in query as,
Images::select($langtitle ,'id', 'title')
->groupBy('id')
->paginate('10');
If it is private, then only 'title'
to be selected. I do not want to use if else case for Query, instead I want to call it using Variable or regex or some method. How can I?
2
Answers
You were on the right track, the only issue you were having is that when the case is
"private"
it will load thecolumn "title"
twice, instead you can do the following:I think you can use the When eloquent function
You can read more about it here.