app/app/Commands/ConfigCommand.php
/**
	 * Execute the console command.
	 *
	 * @return mixed
	 */
Execute the console command.
@return mixed
Execute the console command . @return mixed
public function fire()
	{	
		$this->config = $this->getConfig();
		$opts = $this->option();
		if ($opts['forget']) {
			if (isset(array_dot($this->config)[$opts['forget']])) {
				$keys = explode('.', $opts['forget']);
				array_forget($this->config, $opts['forget']);
				if (empty($this->config[$keys[0]])) {
					DB::table('config')
						->where('name', $keys[0])
						->delete();
				} else {
					DB::table('config')
					->where('name', $keys[0])
					->update(['value' => serialize($this->config[$keys[0]])]);
				}
				$this->info($opts['forget'] . ' removed.');
			}
			return $this->showList();
		}
		if ($opts['key'] && $opts['value']) {
			$value = trim($opts['value']);
			if (in_array($value, ['true', 'false', '0', '1'])) {
				$value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
			}
			$old_config = $this->config;
			array_set($this->config, $opts['key'], $value);
			$keys = explode('.', $opts['key']);
			if (isset($old_config[$keys[0]])) {
				DB::table('config')
					->where('name', $keys[0])
					->update(['value' => serialize($this->config[$keys[0]])]);
			} else {
				DB::table('config')
					->insert(['name' => $keys[0], 'value' => serialize($this->config[$keys[0]])]);
			}
		}
		return $this->showList();
	}
public function fire ( ) { $ this -> config = $ this -> getConfig ( ) ; $ opts = $ this -> option ( ) ; if ( $ opts [ 'forget' ] ) { if ( isset ( array_dot ( $ this -> config ) [ $ opts [ 'forget' ] ] ) ) { $ keys = explode ( '.' , $ opts [ 'forget' ] ) ; array_forget ( $ this -> config , $ opts [ 'forget' ] ) ; if ( empty ( $ this -> config [ $ keys [ 0 ] ] ) ) { DB :: table ( 'config' ) -> where ( 'name' , $ keys [ 0 ] ) -> delete ( ) ; } else { DB :: table ( 'config' ) -> where ( 'name' , $ keys [ 0 ] ) -> update ( [ 'value' => serialize ( $ this -> config [ $ keys [ 0 ] ] ) ] ) ; } $ this -> info ( $ opts [ 'forget' ] . ' removed.' ) ; } return $ this -> showList ( ) ; } if ( $ opts [ 'key' ] && $ opts [ 'value' ] ) { $ value = trim ( $ opts [ 'value' ] ) ; if ( in_array ( $ value , [ 'true' , 'false' , '0' , '1' ] ) ) { $ value = filter_var ( $ value , FILTER_VALIDATE_BOOLEAN ) ; } $ old_config = $ this -> config ; array_set ( $ this -> config , $ opts [ 'key' ] , $ value ) ; $ keys = explode ( '.' , $ opts [ 'key' ] ) ; if ( isset ( $ old_config [ $ keys [ 0 ] ] ) ) { DB :: table ( 'config' ) -> where ( 'name' , $ keys [ 0 ] ) -> update ( [ 'value' => serialize ( $ this -> config [ $ keys [ 0 ] ] ) ] ) ; } else { DB :: table ( 'config' ) -> insert ( [ 'name' => $ keys [ 0 ] , 'value' => serialize ( $ this -> config [ $ keys [ 0 ] ] ) ] ) ; } } return $ this -> showList ( ) ; }
Execute the console command.
Execute the console command .
//update //insert