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
64
65
66
67
68
69
70
71
72
73
74
75
------------------------
-- Roles MIGRATION --
------------------------
CreateRolesTable = class(Migration)
function CreateRolesTable:up()
Schema.create('roles', function(table)
table:integer('id')
table:integer('name')
table:integer('userId')
end)
end
function CreateRolesTable:down()
Schema.dropIfExists('roles');
end
------------------------
-- Role MODEL --
------------------------
Role = class(Model)
-- Role.user
function Role:relation_User()
return self.belongsTo(User)
end
------------------------
-- Role VIEW --
------------------------
local viewUser = {}
RoleView = class(View)
function RoleView:welcome(user)
-- code
end
------------------------
-- Role CONTROLLER --
------------------------
RoleController = class(Controller)
function RoleController:join(user)
if user.role.id == 100 then
RoleView:welcome(user)
end
end
------------------------
-- Users MIGRATION --
------------------------
CreateUsersTable = class(Migration)
function CreateUsersTable:up()
Schema.create('users', function(table)
table:increments('id')
table:increments('roleId')
end)
end
function CreateUsersTable:down()
Schema.dropIfExists('users');
end
------------------------
-- User MODEL --
------------------------
User = class(Auth.Player)
-- User.role
function User:relation_Role()
return self.hasOne(Role)
end