-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03f1c0d
commit 4d726e2
Showing
14 changed files
with
294 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
app/Http/Resources/Turnout/Diaspora/TurnoutDiasporaAggregatedResource.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Resources\Turnout\Diaspora; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class TurnoutDiasporaAggregatedResource extends JsonResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function toArray(Request $request): array | ||
{ | ||
return [ | ||
/* | ||
* Total number of voters subscribed to the election permanent list . | ||
* @var integer | ||
*/ | ||
'initial_total' => $this->initial_total, | ||
|
||
/* | ||
* Total number of people who voted in the election. | ||
* @var integer | ||
*/ | ||
'total' => $this->total, | ||
|
||
/* | ||
* Array of countries and their respective turnout. | ||
* @var TurnoutDiasporaResource[] | ||
*/ | ||
'uats' => TurnoutDiasporaResource::collection($this->uats), | ||
|
||
]; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
app/Http/Resources/Turnout/Diaspora/TurnoutDiasporaResource.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Resources\Turnout\Diaspora; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class TurnoutDiasporaResource extends JsonResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function toArray(Request $request): array | ||
{ | ||
return [ | ||
/* | ||
* Total number of voters subscribed to the election permanent list . | ||
* @var integer | ||
*/ | ||
'initial_total' => $this->initial_total, | ||
|
||
/* | ||
* Total number of people who voted in the election. | ||
* @var integer | ||
*/ | ||
'total' => $this->total, | ||
|
||
/* | ||
* Country code in ISO2. | ||
* @var string | ||
*/ | ||
'code' => $this->place, | ||
]; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
app/Http/Resources/Turnout/National/TurnoutNationalAggregatedResource.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Resources\Turnout\National; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class TurnoutNationalAggregatedResource extends JsonResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function toArray(Request $request): array | ||
{ | ||
return [ | ||
/* | ||
* Total number of voters subscribed to the election permanent list . | ||
* @var integer | ||
*/ | ||
'initial_total' => $this->initial_total, | ||
|
||
/* | ||
* Total number of people who voted in the election. | ||
* @var integer | ||
*/ | ||
'total' => $this->total, | ||
|
||
/* | ||
* Array uats. | ||
* @var TurnoutNationalResource[] | ||
*/ | ||
'uats' => TurnoutNationalResource::collection($this->uats), | ||
|
||
]; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
app/Http/Resources/Turnout/National/TurnoutNationalResource.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Resources\Turnout\National; | ||
|
||
use App\Models\County; | ||
use App\Models\Locality; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class TurnoutNationalResource extends JsonResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function toArray(Request $request): array | ||
{ | ||
return [ | ||
/* | ||
* Total number of voters subscribed to the election permanent list . | ||
* @var integer | ||
*/ | ||
'initial_total' => $this->initial_total, | ||
|
||
/* | ||
* Total number of people who voted in the election. | ||
* @var integer | ||
*/ | ||
'total' => $this->total, | ||
|
||
/* | ||
* Uat id referenced in nomenclature. | ||
* @var string | ||
*/ | ||
'code' => $this->place, | ||
|
||
/* | ||
* Uat name. | ||
* @var string | ||
*/ | ||
'uat_name' => $this->getUatName($this->place), | ||
]; | ||
} | ||
|
||
private function getUatName(int $place) | ||
{ | ||
$uats = \Cache::rememberForever('uats', function () { | ||
return [ | ||
'localities' => Locality::whereNull('parent_id')->pluck('name', 'id')->toArray(), | ||
'counties' => County::pluck('name', 'id')->toArray(), | ||
]; | ||
}); | ||
|
||
return $uats['localities'][$place] ?? $uats['counties'][$place]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.