77abstract class Model implements RepositoryContract {
88
99 /**
10- * The model instance.
10+ * The repository instance.
1111 *
12- * @var string
12+ * @var \Illuminate\Database\Eloquent\Model
1313 */
14- protected $ model ;
14+ protected $ repo ;
1515
1616 /**
1717 * Create a new repository instance.
@@ -38,7 +38,7 @@ public function all($columns = ['*']) {
3838 * @return \Illuminate\Database\Eloquent\Model
3939 */
4040 public function get ($ columns = ['* ' ]) {
41- return $ this ->model ->get ($ columns );
41+ return $ this ->repo ->get ($ columns );
4242 }
4343
4444 /**
@@ -48,7 +48,7 @@ public function get($columns = ['*']) {
4848 * @return \Illuminate\Database\Eloquent\Model
4949 */
5050 public function find ($ id ) {
51- return $ this ->model ->findOrFail ($ id );
51+ return $ this ->repo ->findOrFail ($ id );
5252 }
5353
5454 /**
@@ -58,7 +58,7 @@ public function find($id) {
5858 * @return bool
5959 */
6060 public function create (array $ attributes ) {
61- return $ this ->model ->create ($ attributes );
61+ return $ this ->repo ->create ($ attributes );
6262 }
6363
6464 /**
@@ -69,7 +69,7 @@ public function create(array $attributes) {
6969 * @return bool
7070 */
7171 public function update (array $ attributes = []) {
72- return $ this ->model ->update ($ attributes );
72+ return $ this ->repo ->update ($ attributes );
7373 }
7474
7575 /**
@@ -80,7 +80,7 @@ public function update(array $attributes = []) {
8080 * @throws \Exception
8181 */
8282 public function delete ($ id ) {
83- return $ this ->model ->findOrFail ($ id )->delete ();
83+ return $ this ->repo ->findOrFail ($ id )->delete ();
8484 }
8585
8686 /**
@@ -90,7 +90,7 @@ public function delete($id) {
9090 */
9191 public function getRouteKey ()
9292 {
93- return $ this ->model ->getAttribute ($ this ->getRouteKeyName ());
93+ return $ this ->repo ->getAttribute ($ this ->getRouteKeyName ());
9494 }
9595
9696 /**
@@ -100,7 +100,7 @@ public function getRouteKey()
100100 */
101101 public function getRouteKeyName ()
102102 {
103- return $ this ->model ->getKeyName ();
103+ return $ this ->repo ->getKeyName ();
104104 }
105105
106106 /**
@@ -111,7 +111,7 @@ public function getRouteKeyName()
111111 */
112112 public function resolveRouteBinding ($ value )
113113 {
114- return $ this ->model ->where ($ this ->getRouteKeyName (), $ value )->first ();
114+ return $ this ->repo ->where ($ this ->getRouteKeyName (), $ value )->first ();
115115 }
116116
117117 /**
@@ -121,7 +121,7 @@ public function resolveRouteBinding($value)
121121 */
122122 public function jsonSerialize ()
123123 {
124- return $ this ->model ->toArray ();
124+ return $ this ->repo ->toArray ();
125125 }
126126
127127 /**
@@ -131,6 +131,6 @@ public function jsonSerialize()
131131 */
132132 public function __toString ()
133133 {
134- return $ this ->model ->toJson ();
134+ return $ this ->repo ->toJson ();
135135 }
136136}
0 commit comments