nyel-dev
10 months ago
15
1
Tips

Can I put if else statements inside methods of models?

Posted 10 months ago by nyel-dev

just looking for best practice for this stuff

class User extends Authenticatable
{
    public function isAdmin() {
    if($this->privilege === 1) {
            return true;
        }
  
        return false;
   }

    public function isOwner() {
    if($this->privilege === 2) {
            return true;
        }
  
        return false;
    }

    public function isCustomer() {
        if($this->privilege === 3) {
        return true;
        }
  
       return false;
    }
}

something like this

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