diff --git a/app/ItemType/Game/ResourceTypeModel.php b/app/ItemType/Game/ResourceTypeModel.php index 77916567..7fabb036 100644 --- a/app/ItemType/Game/ResourceTypeModel.php +++ b/app/ItemType/Game/ResourceTypeModel.php @@ -63,8 +63,6 @@ public function paginatedCollection( array $sort_parameters = [] ): array { - - $select_fields = [ 'resource.id AS resource_id', 'resource.name AS resource_name', diff --git a/app/ItemType/Game/SummaryResourceTypeModel.php b/app/ItemType/Game/SummaryResourceTypeModel.php index 83cae5ba..68dc2638 100644 --- a/app/ItemType/Game/SummaryResourceTypeModel.php +++ b/app/ItemType/Game/SummaryResourceTypeModel.php @@ -78,6 +78,28 @@ public function resourcesSummary( `item_subtype`.`description` AS resource_item_subtype_description, COUNT(`{$this->sub_table}`.`item_id`) AS count" ) + ->selectRaw(" + ( + SELECT + GREATEST( + MAX(`{$this->sub_table}`.`created_at`), + IFNULL(MAX(`{$this->sub_table}`.`updated_at`), 0) + ) + FROM + `{$this->sub_table}` + JOIN + `item` ON + `{$this->sub_table}`.`item_id` = `{$this->table}`.`id` + JOIN + `resource` ON + `{$this->table}`.`resource_id` = `resource`.`id` + WHERE + `resource`.`resource_type_id` = ? + ) AS `last_updated`", + [ + $resource_type_id + ] + ) ->join($this->sub_table, 'item.id', "{$this->sub_table}.item_id") ->join('resource', 'item.resource_id', 'resource.id') ->join('resource_item_subtype', 'resource_item_subtype.resource_id', 'resource.id')