diff --git a/src/Api/ApiKey.php b/src/Api/ApiKey.php index baae2c01e..ffd8d591c 100644 --- a/src/Api/ApiKey.php +++ b/src/Api/ApiKey.php @@ -14,22 +14,16 @@ namespace Flarum\Api; use Flarum\Database\AbstractModel; /** - * @property string $id + * @property int $id + * @property string $key + * @property string|null $allowed_ips + * @property string|null $scopes + * @property int|null $user_id + * @property \Carbon\Carbon $created_at + * @property \Carbon\Carbon|null $last_activity_at */ class ApiKey extends AbstractModel { - /** - * {@inheritdoc} - */ - protected $table = 'api_keys'; - - /** - * Use a custom primary key for this model. - * - * @var bool - */ - public $incrementing = false; - /** * Generate an API key. * diff --git a/src/Discussion/Discussion.php b/src/Discussion/Discussion.php index e73be2dad..cfad12d27 100644 --- a/src/Discussion/Discussion.php +++ b/src/Discussion/Discussion.php @@ -59,11 +59,6 @@ class Discussion extends AbstractModel use EventGeneratorTrait; use ScopeVisibilityTrait; - /** - * {@inheritdoc} - */ - protected $table = 'discussions'; - /** * An array of posts that have been modified during this request. * @@ -72,12 +67,14 @@ class Discussion extends AbstractModel protected $modifiedPosts = []; /** - * {@inheritdoc} + * The attributes that should be mutated to dates. + * + * @var array */ protected $dates = ['created_at', 'last_posted_at', 'hidden_at']; /** - * Casts properties to a specific type. + * The attributes that should be cast to native types. * * @var array */ diff --git a/src/Discussion/UserState.php b/src/Discussion/UserState.php index 221663099..ee856cff5 100644 --- a/src/Discussion/UserState.php +++ b/src/Discussion/UserState.php @@ -42,7 +42,9 @@ class UserState extends AbstractModel protected $table = 'discussion_user'; /** - * {@inheritdoc} + * The attributes that should be mutated to dates. + * + * @var array */ protected $dates = ['last_read_at']; diff --git a/src/Group/Group.php b/src/Group/Group.php index 0ce9741a2..19f1b19fd 100644 --- a/src/Group/Group.php +++ b/src/Group/Group.php @@ -33,11 +33,6 @@ class Group extends AbstractModel use EventGeneratorTrait; use ScopeVisibilityTrait; - /** - * {@inheritdoc} - */ - protected $table = 'groups'; - /** * The ID of the administrator group. */ diff --git a/src/Group/Permission.php b/src/Group/Permission.php index e5e4d872f..745022567 100644 --- a/src/Group/Permission.php +++ b/src/Group/Permission.php @@ -32,7 +32,7 @@ class Permission extends AbstractModel */ public function group() { - return $this->belongsTo(Group::class, 'group_id'); + return $this->belongsTo(Group::class); } /** diff --git a/src/Http/AccessToken.php b/src/Http/AccessToken.php index cd0c6aea4..f3d573710 100644 --- a/src/Http/AccessToken.php +++ b/src/Http/AccessToken.php @@ -24,11 +24,6 @@ use Flarum\User\User; */ class AccessToken extends AbstractModel { - /** - * {@inheritdoc} - */ - protected $table = 'access_tokens'; - /** * Use a custom primary key for this model. * diff --git a/src/Notification/Notification.php b/src/Notification/Notification.php index 6a87ad692..bbae7c4ff 100644 --- a/src/Notification/Notification.php +++ b/src/Notification/Notification.php @@ -45,12 +45,9 @@ use Flarum\User\User; class Notification extends AbstractModel { /** - * {@inheritdoc} - */ - protected $table = 'notifications'; - - /** - * {@inheritdoc} + * The attributes that should be mutated to dates. + * + * @var array */ protected $dates = ['created_at', 'read_at', 'deleted_at']; diff --git a/src/Post/Post.php b/src/Post/Post.php index e4df2b0ad..6f6a131bc 100644 --- a/src/Post/Post.php +++ b/src/Post/Post.php @@ -43,18 +43,17 @@ class Post extends AbstractModel { use EventGeneratorTrait; - /** - * {@inheritdoc} - */ protected $table = 'posts'; /** - * {@inheritdoc} + * The attributes that should be mutated to dates. + * + * @var array */ protected $dates = ['created_at', 'edited_at', 'hidden_at']; /** - * Casts properties to a specific type. + * The attributes that should be cast to native types. * * @var array */ @@ -150,7 +149,7 @@ class Post extends AbstractModel */ public function discussion() { - return $this->belongsTo('Flarum\Discussion\Discussion', 'discussion_id'); + return $this->belongsTo(Discussion::class); } /** @@ -160,7 +159,7 @@ class Post extends AbstractModel */ public function user() { - return $this->belongsTo('Flarum\User\User', 'user_id'); + return $this->belongsTo(User::class); } /** @@ -170,7 +169,7 @@ class Post extends AbstractModel */ public function editUser() { - return $this->belongsTo('Flarum\User\User', 'edited_user_id'); + return $this->belongsTo(User::class, 'edited_user_id'); } /** @@ -180,7 +179,7 @@ class Post extends AbstractModel */ public function hideUser() { - return $this->belongsTo('Flarum\User\User', 'hidden_user_id'); + return $this->belongsTo(User::class, 'hidden_user_id'); } /** diff --git a/src/User/AuthToken.php b/src/User/AuthToken.php index d13fd4e3e..877cd7c24 100644 --- a/src/User/AuthToken.php +++ b/src/User/AuthToken.php @@ -28,7 +28,9 @@ class AuthToken extends AbstractModel protected $table = 'registration_tokens'; /** - * {@inheritdoc} + * The attributes that should be mutated to dates. + * + * @var array */ protected $dates = ['created_at']; diff --git a/src/User/EmailToken.php b/src/User/EmailToken.php index ab0f610a0..085efb101 100644 --- a/src/User/EmailToken.php +++ b/src/User/EmailToken.php @@ -24,12 +24,9 @@ use Flarum\User\Exception\InvalidConfirmationTokenException; class EmailToken extends AbstractModel { /** - * {@inheritdoc} - */ - protected $table = 'email_tokens'; - - /** - * {@inheritdoc} + * The attributes that should be mutated to dates. + * + * @var array */ protected $dates = ['created_at']; @@ -40,6 +37,11 @@ class EmailToken extends AbstractModel */ public $incrementing = false; + /** + * {@inheritdoc} + */ + protected $primaryKey = 'token'; + /** * Generate an email token for the specified user. * diff --git a/src/User/PasswordToken.php b/src/User/PasswordToken.php index cda750209..54c9694b0 100644 --- a/src/User/PasswordToken.php +++ b/src/User/PasswordToken.php @@ -22,12 +22,9 @@ use Flarum\Database\AbstractModel; class PasswordToken extends AbstractModel { /** - * {@inheritdoc} - */ - protected $table = 'password_tokens'; - - /** - * {@inheritdoc} + * The attributes that should be mutated to dates. + * + * @var array */ protected $dates = ['created_at']; diff --git a/src/User/User.php b/src/User/User.php index 16bf9fb64..aad9c5f0b 100644 --- a/src/User/User.php +++ b/src/User/User.php @@ -60,12 +60,9 @@ class User extends AbstractModel use ScopeVisibilityTrait; /** - * {@inheritdoc} - */ - protected $table = 'users'; - - /** - * {@inheritdoc} + * The attributes that should be mutated to dates. + * + * @var array */ protected $dates = [ 'joined_at',