added function for trigger 2

This commit is contained in:
2026-07-06 19:21:20 +03:30
parent dcc8559945
commit fc3792902a
6 changed files with 60 additions and 13 deletions
+13
View File
@@ -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('این شماره موبایل قبلاً ثبت شده است');
}
}
}