public function setNameAttribute(string $name)
    {
        $this->attributes['name'] = $name;
        $this->slug = $slug = str_slug($name);

        if ($this instanceof Model && self::sameSlugs($this, $slug)->exists()) {
            $similarSlugs = self::similarSlugs($this, $slug);
            $postfix = 1;
            $this->slug = $slug.$postfix;
            while ($similarSlugs->has($this->slug)) {
                $postfix++;
                $this->slug = $slug.$postfix;
            }
        }
    }
public function setNameAttribute(string $name)
    {
        $this->attributes['name'] = $name;
        $this->slug = $slug = str_slug($name);

        if ($this instanceof Model && self::sameSlugs($this, $slug)->exists()) {
            $similarSlugs = self::similarSlugs($this, $slug);
            $postfix = 1;
            $this->slug = $slug.$postfix;
            while ($similarSlugs->has($this->slug)) {
                $postfix++;
                $this->slug = $slug.$postfix;
            }
        }
    }
public function setNameAttribute ( string $ name ) { $ this -> attributes [ 'name' ] = $ name ; $ this -> slug = $ slug = str_slug ( $ name ) ; if ( $ this instanceof Model && self :: sameSlugs ( $ this , $ slug ) -> exists ( ) ) { $ similarSlugs = self :: similarSlugs ( $ this , $ slug ) ; $ postfix = 1 ; $ this -> slug = $ slug . $ postfix ; while ( $ similarSlugs -> has ( $ this -> slug ) ) { $ postfix ++ ; $ this -> slug = $ slug . $ postfix ; } } }
Override set name - also updates slug

@param string $name New name value
Override set name - also updates slug