add role model
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
use Hyperf\Database\Model\Relations\HasMany;
|
||||
use Hyperf\DbConnection\Model\Model;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $label
|
||||
* @property string $description
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
*/
|
||||
class Role extends Model
|
||||
{
|
||||
protected ?string $table = 'roles';
|
||||
|
||||
protected array $fillable = [
|
||||
'name',
|
||||
'label',
|
||||
'description',
|
||||
];
|
||||
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* 角色下的用户
|
||||
*/
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class, 'role_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user