Add 'plugi-core/' from commit '6c478c54d048ab2fd5af4e8e79074153fb594c16'

git-subtree-dir: plugi-core
git-subtree-mainline: d4c734cdbd
git-subtree-split: 6c478c54d0
This commit is contained in:
Paul Spenke
2023-06-13 07:27:11 +08:00
151 changed files with 46689 additions and 0 deletions
@@ -0,0 +1,41 @@
<?php
namespace Plugi\Repositories;
use Plugi\Contracts\SettingRepositoryContract;
class SettingRepository extends BaseRepository implements SettingRepositoryContract
{
/**
* The pages database table.
*
* @var string
*/
protected $table = 'settings';
/**
* Replace all website settings by the given data.
*
* @param array $data
* @return bool|object|null
*/
public function updateSettings(array $data)
{
$this->destroyAll();
foreach ($data as $key => $value) {
$isArray = is_array($value) ? 1 : 0;
if ($isArray) {
$value = implode(',', $value);
}
$this->create([
'setting' => $key,
'value' => $value,
'is_array' => $isArray,
]);
}
return true;
}
}