30 lines
665 B
PHP
30 lines
665 B
PHP
<?php
|
|
|
|
namespace App\Repositories\Setting;
|
|
|
|
use App\Models\Setting;
|
|
use App\Repositories\BaseRepository;
|
|
|
|
class SettingRepository extends BaseRepository implements SettingRepositoryInterface
|
|
{
|
|
public function getModel()
|
|
{
|
|
return Setting::class;
|
|
}
|
|
public function getByKey(string $key = '')
|
|
{
|
|
$results = $this->model->where('key', $key)->first();
|
|
return $results ? $results->value : null;
|
|
}
|
|
public function updateOrCreateByKey(string $key, array $data = [])
|
|
{
|
|
|
|
return $this->model->updateOrCreate(
|
|
[
|
|
'key' => $key
|
|
],
|
|
$data
|
|
);
|
|
}
|
|
}
|