Skip to content

Commit

Permalink
Merge pull request #781 from bakaphp/hotfix-email-template-order
Browse files Browse the repository at this point in the history
Merge pull request #772 from bakaphp/release-v1-beta-17
  • Loading branch information
kaioken authored Jan 5, 2024
2 parents 91d4e6a + e8638ec commit 231ab32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Kanvas/Enums/AppEnums.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function getValue(): mixed
self::KANVAS_APP_BRANCH_HEADER => 'X-Kanvas-Location',
self::KANVAS_APP_COMPANY_AUTH_HEADER => 'Company-Authorization', //@deprecated
self::DISPLAYNAME_LOGIN => 'displayname_login',
self::VERSION => '1.0-BETA-17',
self::VERSION => '1.0-BETA-18',
self::ANONYMOUS_USER_ID => -1
};
}
Expand Down
8 changes: 6 additions & 2 deletions src/Kanvas/Templates/Repositories/TemplatesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public static function getByName(string $name, AppInterface $app, ?CompanyInterf
->whereIn('apps_id', [AppEnums::LEGACY_APP_ID->getValue(), $app->getId()])
->where('name', $name)
->whereIn('companies_id', [$companyId, AppEnums::GLOBAL_COMPANY_ID->getValue()])
->orderByRaw('FIELD(companies_id, ?, ?) DESC', [$companyId, AppEnums::GLOBAL_COMPANY_ID->getValue()])
->orderBy('apps_id', 'desc')
->orderByRaw('
CASE
WHEN companies_id = ? AND apps_id = ? THEN 1
WHEN apps_id = ? THEN 2
ELSE 3
END', [$companyId, $app->getId(), $app->getId()])
->firstOrFail();
} catch (ModelNotFoundException $e) {
throw new ExceptionsModelNotFoundException('Template not found - ' . $name);
Expand Down

0 comments on commit 231ab32

Please sign in to comment.