824286145

1870 经验值

<?php

namespace App\Events;

use App\Events\Event;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class UserRegistered extends Event
{
    use SerializesModels;
    public $user;
    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct(User $user)
    {
        $this->user = $user;
    }

    /**
     * Get the channels the event should be broadcast on.
     *
     * @return array
     */
    public function broadcastOn()
    {
        return [];
    }
}
ErrorException in UserRegistered.php line 18: Argument 1 passed to App\Events\UserRegistered::__construct() must be an instance of App\Events\User, instance of App\User given, called in /Users/fanqiang/PHP/www/laravel/laravist/user-signup/app/User.php on line 31 and defined
<?php

namespace App;
//use App\Events\User;
use App\Events\UserRegistered;
use Illuminate\Foundation\Auth\User as Authenticatable;

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

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    public static function register(array $attributes)
    {
        $user = static::create($attributes);
        event(new UserRegistered($user));
        return $user;
    }
}

搜索,按Shift+ mac + / 没有Help Search 的设置