@@ -53,25 +53,25 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function getRemitmentCount(int $sessionCount, int $subscriptionCount, int $sessionPosition): int |
55 | 55 | { |
56 | - if($sessionCount === 0 || $subscriptionCount === 0) |
|
56 | + if ($sessionCount === 0 || $subscriptionCount === 0) |
|
57 | 57 | { |
58 | 58 | return 0; |
59 | 59 | } |
60 | 60 | |
61 | 61 | // Greatest common divisor |
62 | - $gcd = (int)gmp_gcd($sessionCount, $subscriptionCount); |
|
63 | - $sessionsInLoop = (int)($sessionCount / $gcd); |
|
62 | + $gcd = (int) gmp_gcd($sessionCount, $subscriptionCount); |
|
63 | + $sessionsInLoop = (int) ($sessionCount / $gcd); |
|
64 | 64 | $positionInLoop = $sessionPosition % $sessionsInLoop; |
65 | - $subscriptionsInLoop = (int)($subscriptionCount / $gcd); |
|
65 | + $subscriptionsInLoop = (int) ($subscriptionCount / $gcd); |
|
66 | 66 | $extraSubscriptionsInLoop = $subscriptionsInLoop % $sessionsInLoop; |
67 | 67 | |
68 | 68 | // There's is an extra remitment when the modulo decreases compared to the previous session. |
69 | 69 | $prevModulo = ($positionInLoop * $extraSubscriptionsInLoop) % $sessionsInLoop; |
70 | - if($prevModulo > ($prevModulo + $extraSubscriptionsInLoop) % $sessionsInLoop) |
|
70 | + if ($prevModulo > ($prevModulo + $extraSubscriptionsInLoop) % $sessionsInLoop) |
|
71 | 71 | { |
72 | - return (int)floor($subscriptionCount / $sessionCount) + 1; |
|
72 | + return (int) floor($subscriptionCount / $sessionCount) + 1; |
|
73 | 73 | } |
74 | - return (int)floor($subscriptionCount / $sessionCount); |
|
74 | + return (int) floor($subscriptionCount / $sessionCount); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -109,15 +109,14 @@ discard block |
||
109 | 109 | $position = 0; |
110 | 110 | $cashier = 0; |
111 | 111 | $expectedFigures = []; |
112 | - foreach($sessions as $session) |
|
112 | + foreach ($sessions as $session) |
|
113 | 113 | { |
114 | 114 | $figures = $this->makeFigures(0); |
115 | 115 | $figures->cashier->start = $cashier; |
116 | 116 | $figures->cashier->recv = $cashier + $depositAmount; |
117 | 117 | $figures->deposit->count = $depositCount; |
118 | 118 | $figures->deposit->amount = $depositAmount; |
119 | - $figures->remitment->count = !$pool->deposit_fixed ? 1 : |
|
120 | - $this->getRemitmentCount($sessionCount, $subscriptionCount, $position++); |
|
119 | + $figures->remitment->count = !$pool->deposit_fixed ? 1 : $this->getRemitmentCount($sessionCount, $subscriptionCount, $position++); |
|
121 | 120 | $figures->remitment->amount = $remitmentAmount * $figures->remitment->count; |
122 | 121 | $figures->cashier->end = $cashier + $depositAmount - $figures->remitment->amount; |
123 | 122 | $cashier = $figures->cashier->end; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function checkPoolsSubscriptions() |
33 | 33 | { |
34 | - if($this->tenantService->round()->pools()->whereDoesntHave('subscriptions')->count() > 0) |
|
34 | + if ($this->tenantService->round()->pools()->whereDoesntHave('subscriptions')->count() > 0) |
|
35 | 35 | { |
36 | 36 | throw new MessageException(trans('tontine.errors.action') . |
37 | 37 | '<br/>' . trans('tontine.pool.errors.no_subscription')); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function openSession(Session $session) |
79 | 79 | { |
80 | - if($session->opened) |
|
80 | + if ($session->opened) |
|
81 | 81 | { |
82 | 82 | return; |
83 | 83 | } |
@@ -159,6 +159,6 @@ discard block |
||
159 | 159 | Session::STATUS_PENDING => trans('tontine.session.status.pending'), |
160 | 160 | Session::STATUS_OPENED => trans('tontine.session.status.opened'), |
161 | 161 | Session::STATUS_CLOSED => trans('tontine.session.status.closed'), |
162 | - ];; |
|
162 | + ]; ; |
|
163 | 163 | } |
164 | 164 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $this->localeService->setCurrency($tontine->currency_code); |
57 | 57 | // Save as latest tontine id if it has changed. |
58 | 58 | $tontineId = $this->user->properties['latest']['tontine'] ?? 0; |
59 | - if($tontineId === $tontine->id) |
|
59 | + if ($tontineId === $tontine->id) |
|
60 | 60 | { |
61 | 61 | return; |
62 | 62 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $this->round = $round; |
76 | 76 | // Save as latest round id if it has changed. |
77 | 77 | $roundId = $this->user->properties['latest']['round'] ?? 0; |
78 | - if($roundId === $round->id) |
|
78 | + if ($roundId === $round->id) |
|
79 | 79 | { |
80 | 80 | return; |
81 | 81 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected static function booted() |
92 | 92 | { |
93 | - static::addGlobalScope('dates', function (Builder $query) { |
|
93 | + static::addGlobalScope('dates', function(Builder $query) { |
|
94 | 94 | $query->addSelect(['pools.*', 'v.end_at', 'v.start_at', 'v.tontine_id']) |
95 | 95 | ->join(DB::raw('v_pools as v'), 'v.id', '=', 'pools.id'); |
96 | 96 | }); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | |
211 | 211 | public function sessions() |
212 | 212 | { |
213 | - if(!$this->pool_round) |
|
213 | + if (!$this->pool_round) |
|
214 | 214 | { |
215 | 215 | return $this->round->sessions(); |
216 | 216 | } |
@@ -16,7 +16,6 @@ |
||
16 | 16 | */ |
17 | 17 | public function scopePage(Builder $query, int $page, int $limit): Builder |
18 | 18 | { |
19 | - return $page < 1 || $limit < 1 ? $query : |
|
20 | - $query->take($limit)->skip($limit * ($page - 1)); |
|
19 | + return $page < 1 || $limit < 1 ? $query : $query->take($limit)->skip($limit * ($page - 1)); |
|
21 | 20 | } |
22 | 21 | } |
@@ -31,34 +31,34 @@ |
||
31 | 31 | ]); |
32 | 32 | $validator->after(function($validator) use($values) { |
33 | 33 | // No more check if there's already an error. |
34 | - if($validator->errors()->count() > 0) |
|
34 | + if ($validator->errors()->count() > 0) |
|
35 | 35 | { |
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
39 | - $startSession = $this->sessionService->getTontineSession((int)$values['start_session']); |
|
40 | - if(!$startSession) |
|
39 | + $startSession = $this->sessionService->getTontineSession((int) $values['start_session']); |
|
40 | + if (!$startSession) |
|
41 | 41 | { |
42 | 42 | $validator->errors()->add('start_session', trans('tontine.pool.errors.start_session')); |
43 | 43 | } |
44 | - $endSession = $this->sessionService->getTontineSession((int)$values['end_session']); |
|
45 | - if(!$endSession) |
|
44 | + $endSession = $this->sessionService->getTontineSession((int) $values['end_session']); |
|
45 | + if (!$endSession) |
|
46 | 46 | { |
47 | 47 | $validator->errors()->add('end_session', trans('tontine.pool.errors.end_session')); |
48 | 48 | } |
49 | - if($endSession->id === $startSession->id || $endSession->start_at <= $startSession->start_at) |
|
49 | + if ($endSession->id === $startSession->id || $endSession->start_at <= $startSession->start_at) |
|
50 | 50 | { |
51 | 51 | $validator->errors()->add('end_session', trans('tontine.pool.errors.session_dates')); |
52 | 52 | } |
53 | 53 | }); |
54 | - if($validator->fails()) |
|
54 | + if ($validator->fails()) |
|
55 | 55 | { |
56 | 56 | throw new ValidationException($validator); |
57 | 57 | } |
58 | 58 | |
59 | 59 | return [ |
60 | - 'start_session_id' => (int)$values['start_session'], |
|
61 | - 'end_session_id' => (int)$values['end_session'], |
|
60 | + 'start_session_id' => (int) $values['start_session'], |
|
61 | + 'end_session_id' => (int) $values['end_session'], |
|
62 | 62 | ]; |
63 | 63 | } |
64 | 64 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | 'title' => 'required|string|min:5', |
20 | 20 | 'notes' => 'nullable|string', |
21 | 21 | ]); |
22 | - if($validator->fails()) |
|
22 | + if ($validator->fails()) |
|
23 | 23 | { |
24 | 24 | throw new ValidationException($validator); |
25 | 25 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | ]); |
39 | 39 | $validator->after(function($validator) use($values) { |
40 | 40 | // The amount must be greater than 0 when the deposit property is set to fixed. |
41 | - if($values['properties']['deposit']['fixed'] && (float)$values['amount'] <= 0) |
|
41 | + if ($values['properties']['deposit']['fixed'] && (float) $values['amount'] <= 0) |
|
42 | 42 | { |
43 | 43 | $validator->errors()->add('principal', trans('validation.gt.numeric', [ |
44 | 44 | 'attribute' => 'amount', |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | ])); |
47 | 47 | } |
48 | 48 | }); |
49 | - if($validator->fails()) |
|
49 | + if ($validator->fails()) |
|
50 | 50 | { |
51 | 51 | throw new ValidationException($validator); |
52 | 52 | } |
53 | 53 | |
54 | 54 | $validated = $validator->validated(); |
55 | - $validated['amount'] = $this->localeService->convertMoneyToInt((float)$validated['amount']); |
|
55 | + $validated['amount'] = $this->localeService->convertMoneyToInt((float) $validated['amount']); |
|
56 | 56 | return $validated; |
57 | 57 | } |
58 | 58 | } |
@@ -33,14 +33,13 @@ |
||
33 | 33 | 'payable' => 'required|integer|min:1', |
34 | 34 | 'auction' => 'required_if:remit_auction,1|regex:/^\d+(\.\d{1,2})?$/', |
35 | 35 | ]); |
36 | - if($validator->fails()) |
|
36 | + if ($validator->fails()) |
|
37 | 37 | { |
38 | 38 | throw new ValidationException($validator); |
39 | 39 | } |
40 | 40 | |
41 | 41 | $validated = $validator->validated(); |
42 | - $validated['auction'] = empty($validated['auction']) ? 0 : |
|
43 | - $this->localeService->convertMoneyToInt((float)$validated['auction']); |
|
42 | + $validated['auction'] = empty($validated['auction']) ? 0 : $this->localeService->convertMoneyToInt((float) $validated['auction']); |
|
44 | 43 | return $validated; |
45 | 44 | } |
46 | 45 | } |