Initial commit

This commit is contained in:
Developer
2025-04-21 16:03:20 +02:00
commit 2832896157
22874 changed files with 3092801 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Domain\Payments\Models;
use App\Models\Model;
use App\Models\User;
class BankRequisites extends Model
{
public function user()
{
return $this->belongsTo(User::class);
}
public function requisites()
{
return $this->morphOne(Requisites::class, 'requisiteable');
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Domain\Payments\Models;
use App\Models\Model;
use App\Models\User;
class Requisites extends Model
{
public function user()
{
return $this->belongsTo(User::class);
}
public function requisiteable()
{
return $this->morphTo();
}
}

View File

@@ -0,0 +1,63 @@
<?php
namespace App\Domain\Payments\Models;
use App\Models\User;
use App\Models\Model;
use App\Domain\Points\Models\Point;
class Withdrawal extends Model
{
public function getUserPhoneAttribute()
{
return $this->user->phone;
}
public function getUserTypeAttribute()
{
return $this->user->type;
}
public function getRequisitesAttribute()
{
return 'ИНН: ' . $this->user->inn . ' ' .
'БИК: ' . $this->user->bik . ' ' .
'Счет: ' . $this->user->checking_account;
}
public static function getTotalAmountForUserInCurrentMonth($userId)
{
return self::where('user_id', $userId)
->where('status', '<>', 'cancel')
->where('created_at', '>=', now()->startOfMonth())
->where('created_at', '<', now()->startOfMonth()->addMonth())
->sum('amount');
}
public static function canRequestWithdrawalPhysical($userId, $requestedAmount)
{
$totalAmount = self::getTotalAmountForUserInCurrentMonth($userId);
return ($totalAmount + $requestedAmount) <= 12000;
}
public static function canRequestWithdrawalLegal($userId, $requestedAmount)
{
$totalAmount = self::getTotalAmountForUserInCurrentMonth($userId);
return ($totalAmount + $requestedAmount) <= 150000;
}
public function user()
{
return $this->belongsTo(User::class);
}
public function requisites()
{
return $this->belongsTo(Requisites::class);
}
public function point()
{
return $this->belongsTo(Point::class);
}
}