D
D
deadnice2019-08-30 11:17:22
Laravel
deadnice, 2019-08-30 11:17:22

How to add MustVerifyEmail email verification to a model other than users?

In general, it seemed to me that this is enough:

customer.php
<?php

namespace App\Models\Butlers;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Nicolaslopezj\Searchable\SearchableTrait;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;

class Customer extends Authenticatable implements MustVerifyEmail
{
    use SoftDeletes;
    use SearchableTrait;
    use HasApiTokens, Notifiable;

    protected $fillable = ['email', 'password', 'spot_password', 'status', 'first_name', 'last_name', 'phone', 'newsletter', 'sms_verified', 'sms_verification_code','customer_type','company_id'];

    protected $hidden = ['password', 'spot_password', 'created_at', 'updated_at', 'deleted_at'];
}
and the corresponding fields in the database

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
JhaoDa, 2019-08-30
@deadnice

The automatic verification mechanism of soap is triggered by the event Illuminate\Auth\Events\Registered, and the author admitted in the comments that he is trying to trigger it by calling Customer::create(). Why? Mystery.

D
Dmitry Kuznetsov, 2019-08-30
@dima9595

If I'm not mistaken this won't help you. You include the same files (MustVerifyEmail for example), where the application logic is already tied strictly.
You will need to override the necessary methods for your idea.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question