import Information from '#models/information';
import { DateTime } from 'luxon';
export default class InformationController {
    async edit({ view }) {
        let info = await Information.first();
        if (!info) {
            info = await Information.create({
                name: '',
                headline: '',
                contact: '',
                linkedin: null,
                github: null,
                birthday: null,
            });
        }
        return view.render('admin/information/form', { information: info });
    }
    async update({ request, response }) {
        const info = await Information.first();
        if (!info) {
            return response.notFound();
        }
        const body = request.only(['name', 'headline', 'contact', 'linkedin', 'github', 'birthday']);
        const birthday = body.birthday ? DateTime.fromISO(body.birthday) : null;
        await info.merge({ ...body, birthday }).save();
        return response.redirect().back();
    }
}
//# sourceMappingURL=information_controller.js.map