added function for trigger 2
This commit is contained in:
@@ -9,6 +9,7 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
|
||||
|
||||
@@ -80,4 +81,16 @@ class User extends Authenticatable implements JWTSubject
|
||||
public function setPasswordAttribute($value){
|
||||
$this->attributes['password'] = Hash::make($value);
|
||||
}
|
||||
|
||||
public static function isMobileTaken(?string $mobile, ?int $exceptId = null): bool
|
||||
{
|
||||
return Customer::isMobileTakenOnTable(self::class, $mobile, $exceptId);
|
||||
}
|
||||
|
||||
public static function assertMobileUnique(?string $mobile, ?int $exceptId = null): void
|
||||
{
|
||||
if (self::isMobileTaken($mobile, $exceptId)) {
|
||||
throw new UnprocessableEntityHttpException('این شماره موبایل قبلاً ثبت شده است');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user