-1

I am trying to trigger an event whenever an user is created but but this error pops up.

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;

class NewUser
{
  use Dispatchable, InteractsWithSockets, SerializesModels;

    /**
     * Create a new event instance.
     *
     * @return void
     */

    use SerializesModels;

    public $user;

    public function __construct(App\User $user)
    {
        //
        $this->user = $user;

    }


}

I have tried searching for this __sleep function but I can't find it, and I've also tired various things with using use App\User int the top vs in the function parameter itself.

What is the issue?

Sapnesh Naik
  • 11,011
  • 7
  • 63
  • 98
  • You have two `use SerializesModels;`. – Bytewave Sep 04 '17 at 19:08
  • This looks like its down to a typo, but should you encounter genuine conflicts: https://stackoverflow.com/questions/25064470/collisions-with-other-trait-methods – Steve Sep 04 '17 at 19:19

1 Answers1

2

You use the trait SerializesModels twice in your class definition. That causes an error, when the trait is applied a second time. __sleep() just happens to be the first method in the trait. Simplified example

Edit to add: Since you said you didn't find the __sleep() function, it's right here

jh1711
  • 2,288
  • 1
  • 12
  • 20