File tree Expand file tree Collapse file tree 4 files changed +35
-17
lines changed
Expand file tree Collapse file tree 4 files changed +35
-17
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,13 @@ public function index()
1414
1515 public function get ()
1616 {
17- $ result = $ this ->Users ->find ();
17+ $ result = $ this ->Users ->findAll ();
1818
1919 return ['list ' => $ this ->Helper ->toJson ($ result )];
2020 }
21+
22+ public function add ($ data )
23+ {
24+ $ this ->Users ->store ($ data );
25+ }
2126}
Original file line number Diff line number Diff line change 66
77class AppModel extends Model
88{
9- public function where ($ dados = null )
10- {
11- if (!empty ($ dados )) {
12- foreach ($ dados as $ k => $ v ) {
13- if (is_int ($ v )) {
14- $ where [] = "{$ k } = {$ v }" ;
15- } else {
16- $ where [] = "{$ k } = ' {$ v }' " ;
17- }
18- }
199
20- return (count ($ where ) > 1 ) ? implode (' AND ' , $ where ) : ' AND ' .$ where [0 ];
21- }
22-
23- return $ dados ;
24- }
2510}
Original file line number Diff line number Diff line change 33namespace SimpleORM \app \model ;
44
55use SimpleORM \app \model \AppModel ;
6+ use SimpleORM \app \model \contracts \UsersInterface ;
67
7- class Users extends AppModel
8+ class Users extends AppModel implements UsersInterface
89{
910 protected $ table = 't_user ' ;
1011 protected $ pk = 'user_id ' ;
12+
13+ public function findAll ()
14+ {
15+ return $ this ->find ();
16+ }
17+
18+ public function store ($ data )
19+ {
20+ return $ this ->save ($ data );
21+ }
22+
23+ public function remove ($ id )
24+ {
25+
26+ }
1127}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace SimpleORM \app \model \contracts ;
4+
5+ interface UsersInterface
6+ {
7+ public function findAll ();
8+
9+ public function store ($ data );
10+
11+ public function remove ($ id );
12+ }
You can’t perform that action at this time.
0 commit comments