snipe-it/tests/Support/Settings.php

42 lines
858 B
PHP
Raw Normal View History

<?php
namespace Tests\Support;
use App\Models\Setting;
class Settings
{
private Setting $setting;
2023-04-06 17:58:53 -07:00
2023-04-06 17:42:15 -07:00
private function __construct()
{
$this->setting = Setting::factory()->create();
}
2023-04-06 17:58:53 -07:00
public static function initialize(): Settings
2023-04-06 17:42:15 -07:00
{
return new self();
}
2023-04-06 18:46:29 -07:00
public function enableMultipleFullCompanySupport(): Settings
{
2023-04-06 18:46:29 -07:00
return $this->update(['full_multiple_companies_support' => 1]);
}
2023-04-06 17:58:53 -07:00
/**
* @param array $attributes Attributes to modify in the application's settings.
*/
2023-04-06 18:46:29 -07:00
public function set(array $attributes): Settings
2023-04-06 17:48:23 -07:00
{
2023-04-06 18:46:29 -07:00
return $this->update($attributes);
2023-04-06 17:48:23 -07:00
}
2023-04-06 18:46:29 -07:00
private function update(array $attributes): Settings
{
Setting::unguarded(fn() => $this->setting->update($attributes));
2023-04-06 17:50:24 -07:00
Setting::$_cache = null;
2023-04-06 18:46:29 -07:00
return $this;
}
}