SELECT
co.id,
co.title,
co.description,
co.created_at,
co.updated_at,
COALESCE(total_amount.total, 0.00) AS total_amount,
array_to_json(ARRAY_AGG(DISTINCT to_jsonb(c))) AS categories,
array_to_json(ARRAY_AGG(DISTINCT to_jsonb(t))) AS transactions
FROM
companies co
LEFT JOIN (
SELECT
company_id,
SUM(
CASE
WHEN type = 'INCOME' THEN amount
ELSE - amount
END
) AS total
FROM
company_transactions
GROUP BY
company_id
) total_amount ON co.id = total_amount.company_id
LEFT JOIN LATERAL (
SELECT
t.id,
t.description,
t.amount,
t.created_at,
t.type
FROM
company_transactions t
WHERE
t.company_id = co.id
) t ON TRUE
LEFT JOIN LATERAL (
SELECT
c.id,
c.title,
COALESCE(
SUM(
CASE
WHEN tr.type = 'INCOME' THEN tr.amount
ELSE - tr.amount
END
),
0.00
) AS total_amount
FROM
company_categories c
LEFT JOIN company_transactions tr ON c.id = tr.category_id
WHERE
c.company_id = co.id
GROUP BY
c.id
) c ON TRUE
WHERE
co.id = 17
GROUP BY
co.id,
total_amount.total
array_to_json(ARRAY_AGG(DISTINCT to_jsonb(c))) AS categories,
array_to_json(ARRAY_AGG(DISTINCT to_jsonb(t))) AS transactions
const queryRunner = this.dataSource.createQueryRunner();
queryRunner.connect();
queryRunner.startTransaction();
try {
const u = await this.repository
.createQueryBuilder('u', queryRunner)
.update({ password: passwordHash })
.where('email = :email', { email: user.email })
.returning('*')
.updateEntity(true)
.execute();
const p = await this.passwordUpdateLogsRepository
.createQueryBuilder('p', queryRunner)
.insert()
.values({ user: { id: user.id } })
.execute();
queryRunner.commitTransaction();
return new HttpException(lang.ru.passwordChanged, HttpStatus.OK);
} catch (error) {
console.log(error);
queryRunner.rollbackTransaction();
throw new BadRequestException(lang.ru.error);
} finally {
queryRunner.release();
}
npx prisma db push
, а после npm run seed
, как в инструкции призмы и сработало.// import { AbilityBuilder } from '@casl/ability';
const {data} = await this.$axios.get('abilities')
const { can, rules } = new AbilityBuilder();
can(data.data, 'all');
this.$ability.update(rules);
export default function({$auth, route, redirect}) {
// Если не подтверждена почта
if ($auth.loggedIn && !$auth.user.email_verified_at) {
// Не вызывать переадресацию на /auth/verify-email
if (route.path !== '/auth/verify-email') {
return redirect('/auth/verify-email')
}
}
}
<div id="<?php esc_attr( get_theme_mod( 'название-настройки', 'значение-по-умолчание' ) ); ?>"></div>
'active_callback' => function(){
return get_theme_mod( 'position_breadcrumb', 'none' );
},
'active_callback' => function(){
return get_theme_mod( 'position_breadcrumb' ) == 'none';
},
'active_callback' => function(){
return get_theme_mod( 'position_breadcrumb' ) !== 'none';
},
'active_callback' => function(){
return get_theme_mod( 'topbar', true );
},