Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 1x 1x 1x 209x 209x 209x 209x 209x 71x 71x 71x 1x 1x 1x 1x 2x 1x 1x | 'use strict';
const CE = use('C2C/Exceptions');
const configs = use('Config').get('modules.staff.general');
const namespace = configs.namespace;
class SalonService {
static get inject() {
return [
'C2C/Repositories/SalonScheduleRepo',
'C2C/Repositories/SalonRepo',
`C2C/Repositories/SettingRepo`,
`${namespace}/UseCases/GetSalon`,
];
}
constructor(salonScheduleRepo, salonRepo, settingRepo, getSalonUseCase) {
this.salonScheduleRepo = salonScheduleRepo;
this.salonRepo = salonRepo;
this.settingRepo = settingRepo;
this._getSalonUseCase = getSalonUseCase;
}
findScheduleBySalonId(salonId) {
return this.salonScheduleRepo.find({ salonId });
}
async findOrFail(id, optionsConditional) {
const salon = await this.salonRepo.findOne({ id, ...optionsConditional });
Iif (!salon) {
throw CE.NotFoundException.raise('errors.notFound');
}
return salon;
}
async loadRelated(salonInstance) {
await salonInstance.loadMany(['schedules', 'photos', 'properties']);
}
async getCancellationPolicy(salon) {
const policy = await this.settingRepo.getCancellationByName(salon.cancellationPolicy);
return policy;
}
getSurveyResults(salonInstance) {
return salonInstance.surveyResults().with('question.survey').fetch();
}
/**
* @return {Promise}
*/
findByIdOrFail(id) {
return this._getSalonUseCase.execute(id);
}
find(conditions) {
return this.salonRepo.find({ ...conditions });
}
}
module.exports = SalonService;
|