File tree 3 files changed +20
-17
lines changed 3 files changed +20
-17
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
declare (strict_types=1 );
3
- namespace RestJS \Trait ;
3
+ namespace RestJS \Abstract ;
4
4
5
5
use Doctrine \ORM \EntityManager ;
6
6
7
- /** Core Model Functions */
8
- trait Model {
7
+ /** Abstract Model Functions */
8
+ abstract class Model {
9
9
10
10
/** Create Repository from Table */
11
11
private $ repository ;
12
12
13
+ /** Entity or Table */
14
+ private $ table ;
15
+
16
+ /** Abstract Function for Set Table Class */
17
+ abstract protected function setTable ();
18
+
13
19
public function __construct (private EntityManager $ entityManager ) {
20
+ $ this ->table = $ this ->setTable ();
14
21
$ this ->repository = $ entityManager ->getRepository ($ this ->table );
15
22
}
16
23
Original file line number Diff line number Diff line change 2
2
declare (strict_types=1 );
3
3
namespace RestJS \Api \Category ;
4
4
5
- use RestJS \Trait \Model as CoreModel ;
5
+ use RestJS \Abstract \Model as AbstractModel ;
6
6
use RestJS \Api \Category \Category ;
7
7
8
- class Model {
8
+ class Model extends AbstractModel {
9
9
10
- /** Entity or Table Variable */
11
- private $ table = Category::class;
12
-
13
- // Trait Model
14
- use CoreModel;
10
+ protected function setTable () {
11
+ return Category::class;
12
+ }
15
13
}
Original file line number Diff line number Diff line change 2
2
declare (strict_types=1 );
3
3
namespace RestJS \Api \User ;
4
4
5
- use RestJS \Trait \Model as CoreModel ;
5
+ use RestJS \Abstract \Model as AbstractModel ;
6
6
use RestJS \Api \User \User ;
7
7
8
- class Model {
8
+ class Model extends AbstractModel {
9
9
10
- /** Entity or Table Variable */
11
- private $ table = User::class;
12
-
13
- // Trait Model
14
- use CoreModel;
10
+ protected function setTable () {
11
+ return User::class;
12
+ }
15
13
}
You can’t perform that action at this time.
0 commit comments