mirror of
https://github.com/flarum/framework.git
synced 2024-12-01 05:53:45 +08:00
Clean up Eloquent definitions
This commit is contained in:
parent
87bba2186e
commit
0fb81958cb
|
@ -14,22 +14,16 @@ namespace Flarum\Api;
|
||||||
use Flarum\Database\AbstractModel;
|
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
|
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.
|
* Generate an API key.
|
||||||
*
|
*
|
||||||
|
|
|
@ -59,11 +59,6 @@ class Discussion extends AbstractModel
|
||||||
use EventGeneratorTrait;
|
use EventGeneratorTrait;
|
||||||
use ScopeVisibilityTrait;
|
use ScopeVisibilityTrait;
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected $table = 'discussions';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of posts that have been modified during this request.
|
* An array of posts that have been modified during this request.
|
||||||
*
|
*
|
||||||
|
@ -72,12 +67,14 @@ class Discussion extends AbstractModel
|
||||||
protected $modifiedPosts = [];
|
protected $modifiedPosts = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* The attributes that should be mutated to dates.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $dates = ['created_at', 'last_posted_at', 'hidden_at'];
|
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
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -42,7 +42,9 @@ class UserState extends AbstractModel
|
||||||
protected $table = 'discussion_user';
|
protected $table = 'discussion_user';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* The attributes that should be mutated to dates.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $dates = ['last_read_at'];
|
protected $dates = ['last_read_at'];
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,6 @@ class Group extends AbstractModel
|
||||||
use EventGeneratorTrait;
|
use EventGeneratorTrait;
|
||||||
use ScopeVisibilityTrait;
|
use ScopeVisibilityTrait;
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected $table = 'groups';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ID of the administrator group.
|
* The ID of the administrator group.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,7 +32,7 @@ class Permission extends AbstractModel
|
||||||
*/
|
*/
|
||||||
public function group()
|
public function group()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Group::class, 'group_id');
|
return $this->belongsTo(Group::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,11 +24,6 @@ use Flarum\User\User;
|
||||||
*/
|
*/
|
||||||
class AccessToken extends AbstractModel
|
class AccessToken extends AbstractModel
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected $table = 'access_tokens';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use a custom primary key for this model.
|
* Use a custom primary key for this model.
|
||||||
*
|
*
|
||||||
|
|
|
@ -45,12 +45,9 @@ use Flarum\User\User;
|
||||||
class Notification extends AbstractModel
|
class Notification extends AbstractModel
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* The attributes that should be mutated to dates.
|
||||||
*/
|
*
|
||||||
protected $table = 'notifications';
|
* @var array
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
*/
|
||||||
protected $dates = ['created_at', 'read_at', 'deleted_at'];
|
protected $dates = ['created_at', 'read_at', 'deleted_at'];
|
||||||
|
|
||||||
|
|
|
@ -43,18 +43,17 @@ class Post extends AbstractModel
|
||||||
{
|
{
|
||||||
use EventGeneratorTrait;
|
use EventGeneratorTrait;
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected $table = 'posts';
|
protected $table = 'posts';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* The attributes that should be mutated to dates.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $dates = ['created_at', 'edited_at', 'hidden_at'];
|
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
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
@ -150,7 +149,7 @@ class Post extends AbstractModel
|
||||||
*/
|
*/
|
||||||
public function discussion()
|
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()
|
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()
|
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()
|
public function hideUser()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('Flarum\User\User', 'hidden_user_id');
|
return $this->belongsTo(User::class, 'hidden_user_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,7 +28,9 @@ class AuthToken extends AbstractModel
|
||||||
protected $table = 'registration_tokens';
|
protected $table = 'registration_tokens';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* The attributes that should be mutated to dates.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $dates = ['created_at'];
|
protected $dates = ['created_at'];
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,9 @@ use Flarum\User\Exception\InvalidConfirmationTokenException;
|
||||||
class EmailToken extends AbstractModel
|
class EmailToken extends AbstractModel
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* The attributes that should be mutated to dates.
|
||||||
*/
|
*
|
||||||
protected $table = 'email_tokens';
|
* @var array
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
*/
|
||||||
protected $dates = ['created_at'];
|
protected $dates = ['created_at'];
|
||||||
|
|
||||||
|
@ -40,6 +37,11 @@ class EmailToken extends AbstractModel
|
||||||
*/
|
*/
|
||||||
public $incrementing = false;
|
public $incrementing = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected $primaryKey = 'token';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate an email token for the specified user.
|
* Generate an email token for the specified user.
|
||||||
*
|
*
|
||||||
|
|
|
@ -22,12 +22,9 @@ use Flarum\Database\AbstractModel;
|
||||||
class PasswordToken extends AbstractModel
|
class PasswordToken extends AbstractModel
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* The attributes that should be mutated to dates.
|
||||||
*/
|
*
|
||||||
protected $table = 'password_tokens';
|
* @var array
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
*/
|
||||||
protected $dates = ['created_at'];
|
protected $dates = ['created_at'];
|
||||||
|
|
||||||
|
|
|
@ -60,12 +60,9 @@ class User extends AbstractModel
|
||||||
use ScopeVisibilityTrait;
|
use ScopeVisibilityTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* The attributes that should be mutated to dates.
|
||||||
*/
|
*
|
||||||
protected $table = 'users';
|
* @var array
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
*/
|
||||||
protected $dates = [
|
protected $dates = [
|
||||||
'joined_at',
|
'joined_at',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user