Skip to content

Commit

Permalink
Merge branch 'main' of github.com:rickgoemans/laravel-user-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
rickgoemans committed Jun 30, 2023
2 parents dbe63fc + 3c39353 commit d3dfddf
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Services/UserSettingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ public function all(): Collection
public function get(string $group, string $key): ?UserSettingData
{
return $this->registeredSettings
->first(fn(UserSettingData $data) => $data->group === $group
->first(fn (UserSettingData $data) => $data->group === $group
&& $data->key === $key);
}

public function set(string $group, string $key, mixed $payload): ?UserSetting
{
$setting = $this->get($group, $key);

if (!$setting) {
if (! $setting) {
return null;
}

return UserSetting::updateOrCreate([

Check failure on line 49 in src/Services/UserSettingService.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Rickgoemans\LaravelUserSettings\Services\UserSettingService::set() should return Rickgoemans\LaravelUserSettings\Models\UserSetting|null but returns Illuminate\Database\Eloquent\Model.

Check failure on line 49 in src/Services/UserSettingService.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Rickgoemans\LaravelUserSettings\Services\UserSettingService::set() should return Rickgoemans\LaravelUserSettings\Models\UserSetting|null but returns Illuminate\Database\Eloquent\Model.
'group' => $group,
'key' => $key,
'key' => $key,
], [
...$setting->except('created_at', 'updated_at')->all(),
'value' => $payload,
Expand All @@ -59,21 +59,21 @@ public function migrate(): void
{
$user = Auth::user();

if (!$user instanceof Model) {
if (! $user instanceof Model) {
return;
}

Cache::remember("user-settings.{$user->getKey()}", 60 * 60, function() use ($user) {
Cache::remember("user-settings.{$user->getKey()}", 60 * 60, function () use ($user) {
$userSettings = UserSetting::query()
->forUser($user->getKey())
->get();

$this->registeredSettings
->each(function(UserSettingData $data) use ($userSettings) {
$dbSetting = $userSettings->first(fn(UserSetting $setting) => $setting->group == $data->group
->each(function (UserSettingData $data) use ($userSettings) {
$dbSetting = $userSettings->first(fn (UserSetting $setting) => $setting->group == $data->group

Check failure on line 73 in src/Services/UserSettingService.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property Rickgoemans\LaravelUserSettings\Models\UserSetting::$group.

Check failure on line 73 in src/Services/UserSettingService.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property Rickgoemans\LaravelUserSettings\Models\UserSetting::$group.
&& $setting->key == $data->key);

Check failure on line 74 in src/Services/UserSettingService.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property Rickgoemans\LaravelUserSettings\Models\UserSetting::$key.

Check failure on line 74 in src/Services/UserSettingService.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property Rickgoemans\LaravelUserSettings\Models\UserSetting::$key.

if (!$dbSetting) {
if (! $dbSetting) {
UserSetting::create($data->except('defaultValue', 'created_at', 'updated_at')->all());
}
});
Expand Down

0 comments on commit d3dfddf

Please sign in to comment.