-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from williamtcastro/function_create-events
Function create events
- Loading branch information
Showing
28 changed files
with
7,641 additions
and
5,498 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
root = true | ||
|
||
[*] | ||
indent_size = 2 | ||
indent_size = 4 | ||
indent_style = space | ||
end_of_line = lf | ||
charset = utf-8 | ||
|
This file contains 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,3 +1,7 @@ | ||
HOST=127.0.0.1 | ||
PORT=4000 | ||
|
||
NODE_ENV=testing | ||
DB_CONNECTION=sqlite | ||
DB_HOST=127.0.0.1 | ||
DB_PORT=3306 | ||
|
This file contains 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 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,19 @@ | ||
language: node_js | ||
node_js: | ||
- 10.16.3 | ||
cache: npm | ||
|
||
install: | ||
- npm ci | ||
|
||
sricpt: | ||
- adonis test | ||
- npm run build | ||
|
||
deploy: | ||
provider: pages | ||
skip-clanup: true | ||
github-token: $GITHUB_TOKEN | ||
on: | ||
branch: master | ||
|
This file contains 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,46 @@ | ||
/** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */ | ||
const Event = use('App/Models/Event') | ||
|
||
class EventController { | ||
async index() { | ||
const events = Event.query() | ||
.with('user', builder => { | ||
builder.select(['id', 'name']) | ||
}) | ||
.fetch() | ||
return events | ||
} | ||
|
||
async show({ params }) { | ||
const event = await Event.find(params.id) | ||
await event.load('user', builder => { | ||
builder.select(['id', 'name']) | ||
}) | ||
return event | ||
} | ||
|
||
async store({ request, response }) { | ||
const data = request.only([ | ||
'title', | ||
'description', | ||
'location_addres', | ||
'location_city_state', | ||
'start_time', | ||
'event_time', | ||
'user_id', | ||
'event_type', | ||
'language', | ||
'dificult_level', | ||
'max_attendess', | ||
'is_public', | ||
'require_registration', | ||
'website', | ||
]) | ||
|
||
const event = await Event.create(data) | ||
|
||
return response.status(201).json(event) | ||
} | ||
} | ||
|
||
module.exports = EventController |
This file contains 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 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 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,10 @@ | ||
/** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */ | ||
const Model = use('Model') | ||
|
||
class Event extends Model { | ||
user() { | ||
return this.belongsTo('App/Models/User') | ||
} | ||
} | ||
|
||
module.exports = Event |
This file contains 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 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,25 @@ | ||
const Antl = use('Antl') | ||
|
||
class Event { | ||
get validateAll() { | ||
return true | ||
} | ||
|
||
get rules() { | ||
return { | ||
title: 'required', | ||
description: 'required', | ||
location_addres: 'required', | ||
location_city_state: 'required', | ||
start_time: 'required', | ||
event_time: 'required', | ||
user_id: 'required|exists:users,id', | ||
} | ||
} | ||
|
||
get messages() { | ||
return Antl.list('validation') | ||
} | ||
} | ||
|
||
module.exports = Event |
This file contains 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,9 +1,19 @@ | ||
const Antl = use('Antl') | ||
|
||
class Forgot { | ||
get validateAll() { | ||
return true | ||
} | ||
|
||
get rules() { | ||
return { | ||
email: 'email|required', | ||
} | ||
} | ||
|
||
get messages() { | ||
return Antl.list('validation') | ||
} | ||
} | ||
|
||
module.exports = Forgot |
This file contains 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,12 +1,22 @@ | ||
const Antl = use('Antl') | ||
|
||
class RegisterUser { | ||
get validateAll() { | ||
return true | ||
} | ||
|
||
get rules() { | ||
return { | ||
username: 'required|unique:users', | ||
username: 'required', | ||
name: 'required', | ||
email: 'email|required|unique:users', | ||
password: 'required|confirmed', | ||
email: 'email|required', | ||
password: 'required', | ||
} | ||
} | ||
|
||
get messages() { | ||
return Antl.list('validation') | ||
} | ||
} | ||
|
||
module.exports = RegisterUser |
This file contains 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,10 +1,20 @@ | ||
const Antl = use('Antl') | ||
|
||
class Reset { | ||
get validateAll() { | ||
return true | ||
} | ||
|
||
get rules() { | ||
return { | ||
token: 'required', | ||
password: 'required|confirmed', | ||
} | ||
} | ||
|
||
get messages() { | ||
return Antl.list('validation') | ||
} | ||
} | ||
|
||
module.exports = Reset |
This file contains 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,10 +1,19 @@ | ||
const Antl = use('Antl') | ||
class Session { | ||
get validateAll() { | ||
return true | ||
} | ||
|
||
get rules() { | ||
return { | ||
email: 'email|required', | ||
password: 'required', | ||
} | ||
} | ||
|
||
get messages() { | ||
return Antl.list('validation') | ||
} | ||
} | ||
|
||
module.exports = Session |
This file contains 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
Binary file not shown.
This file contains 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 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 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,37 @@ | ||
/** @type {import('@adonisjs/lucid/src/Schema')} */ | ||
const Schema = use('Schema') | ||
|
||
class EventsSchema extends Schema { | ||
up() { | ||
this.create('events', table => { | ||
table.increments() | ||
table | ||
.integer('user_id') | ||
.unsigned() | ||
.references('id') | ||
.inTable('users') | ||
.onDelete('SET NULL') | ||
.onUpdate('CASCADE') | ||
table.string('title').notNullable() | ||
table.text('description').notNullable() | ||
table.string('location_addres').notNullable() | ||
table.string('location_city_state').notNullable() | ||
table.date('start_time').notNullable() | ||
table.time('event_time', { precision: 4 }).notNullable() | ||
table.string('event_type').notNullable() | ||
table.string('language').notNullable() | ||
table.integer('dificult_level').notNullable() | ||
table.integer('max_attendess').notNullable() | ||
table.boolean('is_public').notNullable() | ||
table.boolean('require_registration').notNullable() | ||
table.string('website') | ||
table.timestamps() | ||
}) | ||
} | ||
|
||
down() { | ||
this.drop('events') | ||
} | ||
} | ||
|
||
module.exports = EventsSchema |
Oops, something went wrong.