mirror of
https://github.com/flarum/framework.git
synced 2025-04-27 23:24:03 +08:00
removed references to preferences column, now we need to refactor how notification ppreferences is integrated into the current app
This commit is contained in:
parent
6cfc9182f4
commit
d6fc3a91a6
@ -9,9 +9,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
|
||||||
use Illuminate\Database\Schema\Builder;
|
use Illuminate\Database\Schema\Builder;
|
||||||
use Illuminate\Support\Arr;
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'up' => function (Builder $builder) {
|
'up' => function (Builder $builder) {
|
||||||
|
19
src/User/NotificationPreference.php
Normal file
19
src/User/NotificationPreference.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flarum\User;
|
||||||
|
|
||||||
|
use Flarum\Database\AbstractModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $user_id
|
||||||
|
* @property string $type
|
||||||
|
* @property string $channel
|
||||||
|
* @property bool $enabled
|
||||||
|
*/
|
||||||
|
class NotificationPreference extends AbstractModel
|
||||||
|
{
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
}
|
@ -448,6 +448,11 @@ class User extends AbstractModel
|
|||||||
})->count();
|
})->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function notificationPreferences()
|
||||||
|
{
|
||||||
|
return $this->hasMany(NotificationPreference::class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the values of all registered preferences for this user, by
|
* Get the values of all registered preferences for this user, by
|
||||||
* transforming their stored preferences and merging them with the defaults.
|
* transforming their stored preferences and merging them with the defaults.
|
||||||
@ -461,7 +466,7 @@ class User extends AbstractModel
|
|||||||
return $value['default'];
|
return $value['default'];
|
||||||
}, static::$preferences);
|
}, static::$preferences);
|
||||||
|
|
||||||
$user = Arr::only((array) json_decode($value, true), array_keys(static::$preferences));
|
$user = Arr::only($this->notificationPreferences->toArray(), array_keys(static::$preferences));
|
||||||
|
|
||||||
return array_merge($defaults, $user);
|
return array_merge($defaults, $user);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user