Send welcome email with voucher to user upon successful verification of customer email adddress

This commit is contained in:
Dillon Ngo
2024-03-14 15:52:20 +08:00
parent cc8a12c7b0
commit 36cde82a19
18 changed files with 384 additions and 15 deletions
+20 -1
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use App\Classes\General\Interfaces\KeyValueInterface;
use App\Classes\General\Interfaces\Voucherifiable;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -26,7 +27,8 @@ class User extends AbstractModel implements
AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract,
Voucherifiable
Voucherifiable,
KeyValueInterface
{
use HasRoles, Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail, SoftDeletes;
@@ -101,4 +103,21 @@ class User extends AbstractModel implements
{
return $this->HasMany(UserReward::class, 'user_id', 'id');
}
public function hasAttribute(string $key, $value = null): bool
{
$query = $this->attributes()->where('key', $key);
if ($value !== null) {
$query->where('value', $value);
}
return $query->exists();
}
public function attributes(): MorphMany
{
return $this->morphMany(KeyValuePair::class, 'owner');
}
}