@@ 47-55 (lines=9) @@ | ||
44 | } |
|
45 | } |
|
46 | ||
47 | static public function hasMany($name, $class, $via = NULL){ |
|
48 | $str = strtolower($name); |
|
49 | $name = static::getTable(); |
|
50 | static::$_rs[$str] = (object)[ |
|
51 | 'model' => $class, |
|
52 | 'type' => self::HAS_MANY, |
|
53 | 'via' => $via ? $via : "{$name}_id" |
|
54 | ]; |
|
55 | } |
|
56 | ||
57 | static public function hasOne($name, $class, $via = NULL){ |
|
58 | $str = strtolower($name); |
|
@@ 57-65 (lines=9) @@ | ||
54 | ]; |
|
55 | } |
|
56 | ||
57 | static public function hasOne($name, $class, $via = NULL){ |
|
58 | $str = strtolower($name); |
|
59 | $name = static::getTable(); |
|
60 | static::$_rs[$str] = (object)[ |
|
61 | 'model' => $class, |
|
62 | 'type' => self::HAS_ONE, |
|
63 | 'via' => $via ? $via : "{$name}_id" |
|
64 | ]; |
|
65 | } |
|
66 | ||
67 | public function jsonSerialize(){ |
|
68 | return $this->values; |