Changeset View
Changeset View
Standalone View
Standalone View
src/app/Traits/SettingsTrait.php
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | trait SettingsTrait | ||||
public function setSettings(array $data = []): void | public function setSettings(array $data = []): void | ||||
{ | { | ||||
foreach ($data as $key => $value) { | foreach ($data as $key => $value) { | ||||
$this->storeSetting($key, $value); | $this->storeSetting($key, $value); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Any (additional) properties of this domain. | |||||
* | |||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | |||||
*/ | |||||
public function settings() | |||||
{ | |||||
return $this->hasMany(self::class . 'Setting'); | |||||
} | |||||
/** | |||||
* Create or update a setting. | * Create or update a setting. | ||||
* | * | ||||
* @param string $key Setting name | * @param string $key Setting name | ||||
* @param string|null $value The new value for the setting. | * @param string|null $value The new value for the setting. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
private function storeSetting(string $key, $value): void | private function storeSetting(string $key, $value): void | ||||
Show All 14 Lines |