samedi 19 mai 2018

PHP Tenary: Inline if statment

while there is nothing wrong with the following code its bothering me because I know it could be a simple one line.

if (Auth::user()->id != 1){
    echo User::where('owner', Auth::user()->id)->where('status', 2)->count();
}else {
    echo User::where('status', 2)->count();
}

I am just having problems constructing the statement if someone could advise I have tried several variations of:

echo User::(Auth::user()->id != 1 ? where('owner', Auth::user()->id)->)where('status', 2)->count();

Aucun commentaire:

Enregistrer un commentaire