mardi 5 septembre 2017

Laravel listener not working, column not updating

I created a listener that updates a field in the database when a new user is created. THis is my event.

class NewUser
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $user;

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

/**
 * Get the channels the event should broadcast on.
 *
 * @return Channel|array
 */
public function broadcastOn()
{
    return new PrivateChannel('channel-name');
}
}

and my listener

 public function handle(NewUser $event)
{
    $captainrefid = DB::table('users')->where('referral_id', $event->user->referred_by)->value('referral_id');
    $capdownlnrs = DB::table('users')->where('upliner', $captainrefid)->get();




    if(count($capdownlnrs) > 2){
        return DB::table('users')->where('id', $event->user->id)->update(['upliner' => $captainrefid]);
    }

it does not give any error though. Yet the column us the database is not updating. Can anyone help me as to why?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire