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); } }