feat: Implement project management functionality with CRUD operations and UI integration
Some checks failed
build.yaml / feat: Implement project management functionality with CRUD operations and UI integration (push) Failing after 0s

feat: Implement project management functionality with CRUD operations and UI integration
- added projects_controller.ts for crud operations-
added views Edit-vue , Index.vue and Create.vue
- small adaptions in menu.ts
additional routes is start/routes.ts for projects
This commit is contained in:
Kaimbacher 2025-10-16 15:37:55 +02:00
commit f39fe75340
6 changed files with 551 additions and 1 deletions

View file

@ -0,0 +1,50 @@
// app/controllers/projects_controller.ts
import Project from '#models/project';
import type { HttpContext } from '@adonisjs/core/http';
export default class ProjectsController {
// GET /settings/projects
public async index({ inertia, auth }: HttpContext) {
const projects = await Project.all();
// return inertia.render('Admin/Project/Index', { projects });
return inertia.render('Admin/Project/Index', {
projects: projects,
can: {
edit: await auth.user?.can(['settings']),
create: await auth.user?.can(['settings']),
},
});
}
// GET /settings/projects/create
public async create({ inertia }: HttpContext) {
return inertia.render('Admin/Project/Create');
}
// POST /settings/projects
public async store({ request, response, session }: HttpContext) {
const data = request.only(['label', 'name', 'description']);
await Project.create(data);
session.flash('success', 'Project created successfully');
return response.redirect().toRoute('settings.project.index');
}
// GET /settings/projects/:id/edit
public async edit({ params, inertia }: HttpContext) {
const project = await Project.findOrFail(params.id);
return inertia.render('Admin/Project/Edit', { project });
}
// PUT /settings/projects/:id
public async update({ params, request, response, session }: HttpContext) {
const project = await Project.findOrFail(params.id);
const data = request.only(['label', 'name', 'description']);
await project.merge(data).save();
session.flash('success', 'Project updated successfully');
return response.redirect().toRoute('settings.project.index');
}
}