public function set(string $key, string $value) : self
    {
        if (!$setting = $this->get($key)) {
            $setting = new self($this->getSettingsKey());
        }

        $setting->key = $key;
        $setting->value = $value;

        if (!$setting->save()) {
            throw new Exception(current($setting->getMessages()));
        }

        return $setting;
    }
public function set(string $key, string $value) : self
    {
        if (!$setting = $this->get($key)) {
            $setting = new self($this->getSettingsKey());
        }

        $setting->key = $key;
        $setting->value = $value;

        if (!$setting->save()) {
            throw new Exception(current($setting->getMessages()));
        }

        return $setting;
    }
public function set ( string $ key , string $ value ) : self { if ( ! $ setting = $ this -> get ( $ key ) ) { $ setting = new self ( $ this -> getSettingsKey ( ) ) ; } $ setting -> key = $ key ; $ setting -> value = $ value ; if ( ! $ setting -> save ( ) ) { throw new Exception ( current ( $ setting -> getMessages ( ) ) ) ; } return $ setting ; }
Set the vehicle key
@param Vehicle $vehicle [description]
@param string  $key     [description]
@param string  $value   [description]
Set the vehicle key