-
Notifications
You must be signed in to change notification settings - Fork 0
Added members controller and seeder + factories #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ThibaultLatxague
wants to merge
42
commits into
main
Choose a base branch
from
MemberCRUD
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
9ed8943
Added members controller and seeder + factories
12ead87
Corrected lint and typecheck
105b54f
Ran prettier --write for the files
84c4069
Prettier members_controller.ts
7934ef2
feat(categories): add controller
2b1ab42
Runned prettier
a83d788
Added furniture controller
480229e
Added Products and relation to furniture
f650ed4
Added goods (not product associated)
4685b48
Fixed category_id problem beeing null
4380583
Fixed 0n relationships between goods, products and furnitures
a386e61
Fixed linter naming
9cf1495
Added basic supplier CRUD
5a2f232
Added relation between good and supplier
99615ee
Fixed relation between good and supplier
8c57d31
Added restock
bc93ee0
Added restock files
b71f34f
Fixed member - user relationship
a6ad878
Added stock-movement and stock-batch
9e76ba5
Added logs
bd1c958
Added roles
f6b4dae
Added permission files and unique choices from seeder
700ea43
Added role_permission seeder (not functional)
91af891
Fixed warnings
9c30519
Added fast-passes
53601b2
Added subscription
343321b
chore: format
lucas-luchack c8fc06c
fix: typecheck
lucas-luchack f38090a
Merge branch 'main' into MemberCRUD
lucas-luchack 31e4c19
feat: add missing factories
lucas-luchack 6f75f01
fix
lucas-luchack 5dc4e66
format
lucas-luchack 9cc416b
Update database/factories/permission_factory.ts
ThibaultLatxague 4f9441c
Update database/factories/good_factory.ts
ThibaultLatxague 9a65ed5
Update database/factories/members_factory.ts
ThibaultLatxague 1b5db6a
refactor: replace comma-operator route declarations
Copilot 0cf963c
chore: revert unrelated generated adonis index updates
Copilot e978bc7
Resolved conflicts
48d3b7e
Corrected Copilot mistakes
e337545
Runned pnpm run format for prettier
4f98e98
Merge branch 'main' into MemberCRUD
ThibaultLatxague 04294c4
Apply suggestion from @Copilot
ThibaultLatxague File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,10 @@ | ||
| /** | ||
| * This file is automatically generated. | ||
| * DO NOT EDIT manually | ||
| */ | ||
|
|
||
| /// <reference path="../../adonisrc.ts" /> | ||
| /// <reference path="../../config/auth.ts" /> | ||
| /// <reference path="../../config/hash.ts" /> | ||
| /// <reference path="../../config/jwt.ts" /> | ||
| /// <reference path="../../config/logger.ts" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,23 @@ | ||
| /** | ||
| * This file is automatically generated. | ||
| * DO NOT EDIT manually | ||
| */ | ||
|
|
||
| export const controllers = { | ||
| AccessToken: () => import('#controllers/access_token_controller'), | ||
| Categories: () => import('#controllers/categories_controller'), | ||
| FastPasses: () => import('#controllers/fast_passes_controller'), | ||
| Furnitures: () => import('#controllers/furnitures_controller'), | ||
| Goods: () => import('#controllers/goods_controller'), | ||
| Logs: () => import('#controllers/logs_controller'), | ||
| Members: () => import('#controllers/members_controller'), | ||
| NewAccount: () => import('#controllers/new_account_controller'), | ||
| Permissions: () => import('#controllers/permissions_controller'), | ||
| Products: () => import('#controllers/products_controller'), | ||
| Profile: () => import('#controllers/profile_controller'), | ||
| Restocks: () => import('#controllers/restocks_controller'), | ||
| Roles: () => import('#controllers/roles_controller'), | ||
| StockBatches: () => import('#controllers/stock_batches_controller'), | ||
| StockMovements: () => import('#controllers/stock_movements_controller'), | ||
| Suppliers: () => import('#controllers/suppliers_controller'), | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,6 @@ | ||
| /** | ||
| * This file is automatically generated. | ||
| * DO NOT EDIT manually | ||
| */ | ||
|
|
||
| export const events = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,6 @@ | ||
| /** | ||
| * This file is automatically generated. | ||
| * DO NOT EDIT manually | ||
| */ | ||
|
|
||
| export const listeners = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import type { HttpContext } from '@adonisjs/core/http' | ||
| import Category from '#models/category' | ||
|
|
||
| export default class CategoriesController { | ||
| /** | ||
| * Display a list of resource | ||
| */ | ||
| async index({}: HttpContext) { | ||
| return Category.all() | ||
| } | ||
|
|
||
| /** | ||
| * Handle form submission for the create action | ||
| */ | ||
| async store({ request }: HttpContext) { | ||
| const data = request.all() | ||
| return Category.create(data) | ||
| } | ||
|
|
||
| /** | ||
| * Show individual record | ||
| */ | ||
| async show({ params }: HttpContext) { | ||
| return Category.findOrFail(params.id) | ||
| } | ||
|
|
||
| /** | ||
| * Handle form submission for the edit action | ||
| */ | ||
| async update({ params, request }: HttpContext) { | ||
| const category = await Category.findOrFail(params.id) | ||
| const data = request.all() | ||
| category.merge(data) | ||
| return category.save() | ||
| } | ||
|
|
||
| /** | ||
| * Delete record | ||
| */ | ||
| async destroy({ params }: HttpContext) { | ||
| const category = await Category.findOrFail(params.id) | ||
| return category.delete() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import type { HttpContext } from '@adonisjs/core/http' | ||
| import FastPass from '#models/fast_pass' | ||
|
|
||
| export default class FastPassesController { | ||
| /** | ||
| * Display a list of resource | ||
| */ | ||
| async index({}: HttpContext) { | ||
| return FastPass.query() | ||
| } | ||
|
|
||
| /** | ||
| * Handle form submission for the create action | ||
| */ | ||
| async store({ request }: HttpContext) { | ||
| const { price, duration, description, label } = request.all() | ||
| const fastPass = new FastPass() | ||
| fastPass.price = price | ||
| fastPass.duration = duration | ||
| fastPass.description = description | ||
| fastPass.label = label | ||
| await fastPass.save() | ||
| return fastPass | ||
| } | ||
|
|
||
| /** | ||
| * Show individual record | ||
| */ | ||
| async show({ params }: HttpContext) { | ||
| return FastPass.query().where('id', params.id).firstOrFail() | ||
| } | ||
|
|
||
| /** | ||
| * Handle form submission for the edit action | ||
| */ | ||
| async update({ params, request }: HttpContext) { | ||
| const fastPass = await FastPass.query().where('id', params.id).firstOrFail() // We get our fast pass by id | ||
| const { price, duration, description, label } = request.all() // We transfer the new data from the request to constants | ||
| fastPass.price = price // Assigning the data | ||
| fastPass.duration = duration | ||
| fastPass.description = description | ||
| fastPass.label = label | ||
| await fastPass.save() // We save the fast pass to the database | ||
| return fastPass | ||
| } | ||
|
|
||
| /** | ||
| * Delete record | ||
| */ | ||
| async destroy({ params }: HttpContext) { | ||
| const fastPass = await FastPass.query().where('id', params.id).firstOrFail() | ||
| await fastPass.delete() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import type { HttpContext } from '@adonisjs/core/http' | ||
| import Furniture from '#models/furniture' | ||
|
|
||
| export default class FurnituresController { | ||
| /** | ||
| * Display a list of resource | ||
| */ | ||
| async index({}: HttpContext) { | ||
| return Furniture.all() | ||
| } | ||
|
|
||
| /** | ||
| * Handle form submission for the create action | ||
| */ | ||
| async store({ request }: HttpContext) { | ||
| const { name, quantity, price } = request.all() | ||
| return Furniture.create({ name, quantity, price }) | ||
| } | ||
|
|
||
| /** | ||
| * Show individual record | ||
| */ | ||
| async show({ params }: HttpContext) { | ||
| return Furniture.findOrFail(params.id) | ||
| } | ||
|
|
||
| /** | ||
| * Handle form submission for the edit action | ||
| */ | ||
| async update({ params, request }: HttpContext) { | ||
| const furniture = await Furniture.findOrFail(params.id) | ||
| const { name, quantity, price } = request.all() | ||
| furniture.merge({ name, quantity, price }) | ||
| return furniture.save() | ||
| } | ||
|
|
||
| /** | ||
| * Delete record | ||
| */ | ||
| async destroy({ params }: HttpContext) { | ||
| const furniture = await Furniture.findOrFail(params.id) | ||
| return furniture.delete() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import type { HttpContext } from '@adonisjs/core/http' | ||
| import Good from '#models/good' | ||
|
|
||
| export default class GoodsController { | ||
| /** | ||
| * Display a list of resource | ||
| */ | ||
| async index({}: HttpContext) { | ||
| return Good.query().preload('products').preload('category').preload('suppliers') | ||
| } | ||
|
|
||
| /** | ||
| * Handle form submission for the create action | ||
| */ | ||
| async store({ request }: HttpContext) { | ||
| const { name, unit, brand, categoryId } = request.all() | ||
| const good = new Good() | ||
| good.name = name | ||
| good.unit = unit | ||
| good.brand = brand | ||
| good.categoryId = categoryId | ||
| await good.save() | ||
| return good | ||
| } | ||
|
|
||
| /** | ||
| * Show individual record | ||
| */ | ||
| async show({ params }: HttpContext) { | ||
| return await Good.query() | ||
| .preload('products') | ||
| .preload('category') | ||
| .preload('suppliers') | ||
| .where('id', params.id) | ||
| .firstOrFail() | ||
| } | ||
|
|
||
| /** | ||
| * Handle form submission for the edit action | ||
| */ | ||
| async update({ params, request }: HttpContext) { | ||
| const good = await Good.query() | ||
| .preload('products') | ||
| .preload('category') | ||
| .preload('suppliers') | ||
| .where('id', params.id) | ||
| .firstOrFail() // We get our good by id | ||
| const { name, unit, brand, categoryId } = request.all() | ||
| good.name = name | ||
| good.unit = unit | ||
| good.brand = brand | ||
| good.categoryId = categoryId | ||
| await good.save() | ||
| return good | ||
| } | ||
|
|
||
| /** | ||
| * Delete record | ||
| */ | ||
| async destroy({ params }: HttpContext) { | ||
| const good = await Good.query() | ||
| .preload('products') | ||
| .preload('category') | ||
| .preload('suppliers') | ||
| .where('id', params.id) | ||
| .firstOrFail() | ||
| await good.delete() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import type { HttpContext } from '@adonisjs/core/http' | ||
| import Log from '#models/log' | ||
|
|
||
| export default class LogsController { | ||
| /** | ||
| * Display a list of resource | ||
| */ | ||
| async index({}: HttpContext) { | ||
| const logs = await Log.query().preload('user') | ||
| return logs | ||
| } | ||
|
|
||
| /** | ||
| * Handle form submission for the create action | ||
| */ | ||
| async store({ request }: HttpContext) { | ||
| const { level, message, method, url, ip, meta, userId } = request.all() | ||
| const log = await Log.create({ | ||
| level, | ||
| message, | ||
| method, | ||
| url, | ||
| ip, | ||
| meta, | ||
| userId, | ||
| }) | ||
| return log | ||
| } | ||
|
|
||
| /** | ||
| * Show individual record | ||
| */ | ||
| async show({ params }: HttpContext) { | ||
| const log = await Log.query().where('id', params.id).preload('user').firstOrFail() | ||
| return log | ||
| } | ||
|
|
||
| /** | ||
| * Handle form submission for the edit action | ||
| */ | ||
| async update({ params, request }: HttpContext) { | ||
| const log = await Log.query().where('id', params.id).firstOrFail() | ||
| const { level, message, method, url, ip, meta, userId } = request.all() | ||
| log.level = level | ||
| log.message = message | ||
| log.method = method | ||
| log.url = url | ||
| log.ip = ip | ||
| log.meta = meta | ||
| log.userId = userId | ||
| await log.save() | ||
| return log | ||
| } | ||
|
|
||
| /** | ||
| * Delete record | ||
| */ | ||
| async destroy({ params }: HttpContext) { | ||
| const log = await Log.query().where('id', params.id).preload('user').firstOrFail() | ||
| await log.delete() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import type { HttpContext } from '@adonisjs/core/http' | ||
| import Member from '#models/member' | ||
|
|
||
| export default class MembersController { | ||
| /** | ||
| * Display a list of resource | ||
| */ | ||
| async index({}: HttpContext) { | ||
| const members = await Member.query().preload('role') | ||
| return members | ||
| } | ||
|
|
||
| /** | ||
| * Handle form submission for the create action | ||
| */ | ||
| async store({ request }: HttpContext) { | ||
| const { firstName, lastName } = request.all() | ||
| const member = new Member() | ||
| member.firstName = firstName | ||
| member.lastName = lastName | ||
| await member.save() | ||
| return member | ||
|
ThibaultLatxague marked this conversation as resolved.
|
||
| } | ||
|
|
||
| /** | ||
| * Show individual record | ||
| */ | ||
| async show({ params }: HttpContext) { | ||
| const member = await Member.query().preload('role').where('id', params.id).first() | ||
| if (!member) { | ||
| throw new Error('Member not found') | ||
| } | ||
|
ThibaultLatxague marked this conversation as resolved.
|
||
| return member | ||
| } | ||
|
|
||
| /** | ||
| * Handle form submission for the edit action | ||
| */ | ||
| async update({ params, request }: HttpContext) { | ||
| const member = await Member.query().preload('role').where('id', params.id).first() | ||
| if (!member) { | ||
| throw new Error('Member not found') | ||
| } | ||
|
ThibaultLatxague marked this conversation as resolved.
|
||
| const { firstName, lastName } = request.all() | ||
| member.firstName = firstName | ||
| member.lastName = lastName | ||
| await member.save() | ||
| return member | ||
| } | ||
|
|
||
| /** | ||
| * Delete record | ||
| */ | ||
| async destroy({ params }: HttpContext) { | ||
| const member = await Member.query().preload('role').where('id', params.id).first() | ||
| if (!member) { | ||
| throw new Error('Member not found') | ||
| } | ||
| await member.delete() | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.