weiman99
1 month ago
324
6
Laravel

Laravel email verification

Posted 1 month ago by weiman99

I am doing the email verification in laravel, when i Verify email address in mailstrap.oi then have some errors

InvalidArgumentException
The separation symbol could not be found
 Unexpected data found.
 Unexpected data found.
 Unexpected data found.
 Trailing data

Below is my User.php

<?php

namespace App;

use App\Notifications\VerifyUserNotification;
use Carbon\Carbon;
use Hash;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Str;
use Laravel\Passport\HasApiTokens;

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

    public $table = 'users';

    protected $hidden = [
        'password',
        'remember_token',
    ];

    protected $dates = [
        'updated_at',
        'created_at',
        'deleted_at',
        'email_verified_at',
    ];

    protected $fillable = [
        'name',
        'email',
        'password',
        'approved',
        'created_at',
        'updated_at',
        'deleted_at',
        'remember_token',
        'email_verified_at',
    ];


    public function getIsAdminAttribute()
    {
        return $this->roles()->where('id', 1)->exists();
    }

    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);
        self::created(function (User $user) {
            $registrationRole = config('panel.registration_default_role');

            if (!$user->roles()->get()->contains($registrationRole)) {
                $user->roles()->attach($registrationRole);
            }
        });
    }

    public function assignedToTasks()
    {
        return $this->hasMany(Task::class, 'assigned_to_id', 'id');
    }

    public function userCustomers()
    {
        return $this->hasMany(Customer::class, 'user_id', 'id');
    }

    public function userTimelines()
    {
        return $this->hasMany(Timeline::class, 'user_id', 'id');
    }

    public function userClients()
    {
        return $this->hasMany(Client::class, 'user_id', 'id');
    }

    public function userWorkHistories()
    {
        return $this->hasMany(WorkHistory::class, 'user_id', 'id');
    }

    public function userGovInfos()
    {
        return $this->hasMany(GovInfo::class, 'user_id', 'id');
    }

    public function userClientDetails()
    {
        return $this->hasMany(ClientDetail::class, 'user_id', 'id');
    }

    public function userCandidateDetails()
    {
        return $this->hasMany(CandidateDetail::class, 'user_id', 'id');
    }

    public function userTaskStatuses()
    {
        return $this->hasMany(TaskStatus::class, 'user_id', 'id');
    }

    public function userTaskTags()
    {
        return $this->hasMany(TaskTag::class, 'user_id', 'id');
    }

    public function userTasks()
    {
        return $this->hasMany(Task::class, 'user_id', 'id');
    }

    public function userProjects()
    {
        return $this->hasMany(Project::class, 'user_id', 'id');
    }

    public function userNotes()
    {
        return $this->hasMany(Note::class, 'user_id', 'id');
    }

    public function userDocuments()
    {
        return $this->hasMany(Document::class, 'user_id', 'id');
    }

    public function userTransactions()
    {
        return $this->hasMany(Transaction::class, 'user_id', 'id');
    }

    public function userFaqCategories()
    {
        return $this->hasMany(FaqCategory::class, 'user_id', 'id');
    }

    public function userFaqQuestions()
    {
        return $this->hasMany(FaqQuestion::class, 'user_id', 'id');
    }

    public function userTimeWorkTypes()
    {
        return $this->hasMany(TimeWorkType::class, 'user_id', 'id');
    }

    public function userTimeProjects()
    {
        return $this->hasMany(TimeProject::class, 'user_id', 'id');
    }

    public function userTimeEntries()
    {
        return $this->hasMany(TimeEntry::class, 'user_id', 'id');
    }

    public function userContactCompanies()
    {
        return $this->hasMany(ContactCompany::class, 'user_id', 'id');
    }

    public function userContactContacts()
    {
        return $this->hasMany(ContactContact::class, 'user_id', 'id');
    }

    public function userCurrencies()
    {
        return $this->hasMany(Currency::class, 'user_id', 'id');
    }

    public function userTransactionTypes()
    {
        return $this->hasMany(TransactionType::class, 'user_id', 'id');
    }

    public function userIncomeSources()
    {
        return $this->hasMany(IncomeSource::class, 'user_id', 'id');
    }

    public function userClientStatuses()
    {
        return $this->hasMany(ClientStatus::class, 'user_id', 'id');
    }

    public function userProjectStatuses()
    {
        return $this->hasMany(ProjectStatus::class, 'user_id', 'id');
    }

    public function userWorkers()
    {
        return $this->hasMany(Worker::class, 'user_id', 'id');
    }

    public function userInboxes()
    {
        return $this->hasMany(Inbox::class, 'user_id', 'id');
    }

    public function createdByCustomers()
    {
        return $this->hasMany(Customer::class, 'created_by_id', 'id');
    }

    public function createdByGovInfos()
    {
        return $this->hasMany(GovInfo::class, 'created_by_id', 'id');
    }

    public function createdByClientDetails()
    {
        return $this->hasMany(ClientDetail::class, 'created_by_id', 'id');
    }

    public function createdByTimelines()
    {
        return $this->hasMany(Timeline::class, 'created_by_id', 'id');
    }

    public function createdByWorkers()
    {
        return $this->hasMany(Worker::class, 'created_by_id', 'id');
    }

    public function userLicenses()
    {
        return $this->hasMany(License::class, 'user_id', 'id');
    }

    public function createdByLicenses()
    {
        return $this->hasMany(License::class, 'created_by_id', 'id');
    }

    public function userUserAlerts()
    {
        return $this->belongsToMany(UserAlert::class);
    }

    public function getEmailVerifiedAtAttribute($value)
    {
        return $value ? Carbon::createFromFormat('Y-m-d H:i:s', $value)->format(config('panel.date_format') . ' ' . config('panel.time_format')) : null;
    }

    public function setEmailVerifiedAtAttribute($value)
    {
        $this->attributes['email_verified_at'] = $value ? Carbon::createFromFormat(config('panel.date_format') . ' ' . config('panel.time_format'), $value)->format('Y-m-d H:i:s') : null;
    }

    public function setPasswordAttribute($input)
    {
        if ($input) {
            $this->attributes['password'] = app('hash')->needsRehash($input) ? Hash::make($input) : $input;
        }
    }

    public function sendPasswordResetNotification($token)
    {
        $this->notify(new ResetPassword($token));
    }

    public function roles()
    {
        return $this->belongsToMany(Role::class);
    }
}

Please sign in or create an account to participate in this conversation.