如何扩展User.php的多种功能

如何扩展User.php的多种功能,php,laravel,laravel-6,Php,Laravel,Laravel 6,我不熟悉编码,我正在尝试扩展\TCG\Voyager\Models\User和authenticable同时实现MustVerifyEmail,但我不知道如何做到这一点 我试过classUser扩展\TCG\Voyager\Models\User,authenticable一起实现MustVerifyEmail,但这对我不起作用 我已经创建了两个独立的类,这也不允许我 namespace App; use Illuminate\Notifications\Notifiable; use Il

我不熟悉编码,我正在尝试扩展
\TCG\Voyager\Models\User
authenticable
同时实现
MustVerifyEmail
,但我不知道如何做到这一点

我试过class
User
扩展
\TCG\Voyager\Models\User
authenticable
一起实现
MustVerifyEmail
,但这对我不起作用

我已经创建了两个独立的类,这也不允许我


namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements MustVerifyEmail extends \TCG\Voyager\Models\User
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}
PHP
中不能扩展两个(或更多)类,只能扩展一个。解决办法可以是:

  • A类
    扩展
    B类
  • B类
    扩展
    C类
这样,
A类
也将扩展
C类
(通过
B类

就你而言:

  • User
    扩展了
    \TCG\Voyager\Models\User
    并实现了
    MustVerifyEmail
  • \TCG\Voyager\Models\User
    extends
    authenticable


这是其中一个原因,特性是在PHP世界中引入的(虽然不一样)。

可能重复的特性,那么我将如何编写它。我是新手,所以很难理解。