1 year ago

setting getRouteKeyName if a condition is met

Posted 1 year ago by ristlin

So I'd only like to set my own route key name if the column is not null (i.e., the user has explicitly set their URL name). I've tried the following, but I can't seem to get it to work. Basically, the conditionals are ignored.

  public function getRouteKeyName()
    // if the user has set a url name, set it as the key name
        if ('link_name' != null) {
            return 'link_name';
    // otherwise, return default
    return 'id';

Any suggestions?

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