summaryrefslogtreecommitdiff
path: root/src/http/Controller/Village.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/Controller/Village.php')
-rw-r--r--src/http/Controller/Village.php44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/http/Controller/Village.php b/src/http/Controller/Village.php
index 7b1f227..2d6aa39 100644
--- a/src/http/Controller/Village.php
+++ b/src/http/Controller/Village.php
@@ -4,6 +4,8 @@ namespace App\http\Controller;
use App\DB;
use App\Guard;
+use App\Model\Event\SendResources;
+use App\Model\Event\SendResourcesCarriers;
use App\Model\Event\SendUnits;
use App\Model\Event\TrainUnits;
use App\Model\Event\UpgradeBuilding;
@@ -27,7 +29,7 @@ class Village
join user_villages on villages.id = user_villages.village_id
where user_villages.user_id=:id
SQL,
- ['id' => $_SESSION['user']['id']]
+ ['id' => $_SESSION['user']['id'] ?? -1]
);
return new Response(View::render('villages.twig', [
@@ -90,6 +92,46 @@ class Village
$events['SendUnits'][] = DB::convertToModel(SendUnits::class, $row);;
}
+ $eventsResourcesSendOwn = DB::query(
+ <<<SQL
+ select * from events_send_resources as event
+ left join events on event.event_id = events.id
+ where village_id=:id
+ SQL, ['id' => $village->id]
+ )->fetchAll();
+
+ $eventsResourcesSendOther = DB::query(
+ <<<SQL
+ select * from events_send_resources as event
+ left join events on event.event_id = events.id
+ where (destination=:id or source=:id) and village_id!=:id and is_canceled=false
+ SQL, ['id' => $village->id]
+ )->fetchAll();
+
+ foreach ([...$eventsResourcesSendOwn, ...$eventsResourcesSendOther] as $row) {
+ $events['SendResources'][] = DB::convertToModel(SendResources::class, $row);;
+ }
+
+ $eventsResourcesCarriersSendOwn = DB::query(
+ <<<SQL
+ select * from events_send_resources_carriers as event
+ left join events on event.event_id = events.id
+ where village_id=:id
+ SQL, ['id' => $village->id]
+ )->fetchAll();
+
+ $eventsResourcesCarriersSendOther = DB::query(
+ <<<SQL
+ select * from events_send_resources_carriers as event
+ left join events on event.event_id = events.id
+ where (destination=:id or source=:id) and village_id!=:id
+ SQL, ['id' => $village->id]
+ )->fetchAll();
+
+ foreach ([...$eventsResourcesCarriersSendOwn, ...$eventsResourcesCarriersSendOther] as $row) {
+ $events['SendResourcesCarriers'][] = DB::convertToModel(SendResourcesCarriers::class, $row);;
+ }
+
$buildings = [];
foreach (Model::getBuildings($village->id, true) as $building) {
$buildings[$building->type] = $building;