@@ -11,15 +11,17 @@ abstract class Model implements RepositoryContract {
1111 *
1212 * @var \Illuminate\Database\Eloquent\Model
1313 */
14- protected $ repo ;
14+ protected $ repository ;
1515
1616 /**
1717 * Create a new repository instance.
1818 *
1919 * @param \Illuminate\Database\Eloquent\Model $model
2020 * @return void
2121 */
22- public function __construct ($ model ) {}
22+ public function __construct ($ model ) {
23+ $ this ->repository = $ model ;
24+ }
2325
2426 /**
2527 * Get all of the models from the database.
@@ -38,7 +40,7 @@ public function all($columns = ['*']) {
3840 * @return \Illuminate\Database\Eloquent\Model
3941 */
4042 public function get ($ columns = ['* ' ]) {
41- return $ this ->repo ->get ($ columns );
43+ return $ this ->repository ->get ($ columns );
4244 }
4345
4446 /**
@@ -48,7 +50,7 @@ public function get($columns = ['*']) {
4850 * @return \Illuminate\Database\Eloquent\Model
4951 */
5052 public function find ($ id ) {
51- return $ this ->repo ->findOrFail ($ id );
53+ return $ this ->repository ->findOrFail ($ id );
5254 }
5355
5456 /**
@@ -58,7 +60,7 @@ public function find($id) {
5860 * @return bool
5961 */
6062 public function create (array $ attributes ) {
61- return $ this ->repo ->create ($ attributes );
63+ return $ this ->repository ->create ($ attributes );
6264 }
6365
6466 /**
@@ -69,7 +71,7 @@ public function create(array $attributes) {
6971 * @return bool
7072 */
7173 public function update (array $ attributes = []) {
72- return $ this ->repo ->update ($ attributes );
74+ return $ this ->repository ->update ($ attributes );
7375 }
7476
7577 /**
@@ -80,7 +82,7 @@ public function update(array $attributes = []) {
8082 * @throws \Exception
8183 */
8284 public function delete ($ id ) {
83- return $ this ->repo ->findOrFail ($ id )->delete ();
85+ return $ this ->repository ->findOrFail ($ id )->delete ();
8486 }
8587
8688 /**
@@ -90,7 +92,7 @@ public function delete($id) {
9092 */
9193 public function getRouteKey ()
9294 {
93- return $ this ->repo ->getAttribute ($ this ->getRouteKeyName ());
95+ return $ this ->repository ->getAttribute ($ this ->getRouteKeyName ());
9496 }
9597
9698 /**
@@ -100,7 +102,7 @@ public function getRouteKey()
100102 */
101103 public function getRouteKeyName ()
102104 {
103- return $ this ->repo ->getKeyName ();
105+ return $ this ->repository ->getKeyName ();
104106 }
105107
106108 /**
@@ -111,7 +113,7 @@ public function getRouteKeyName()
111113 */
112114 public function resolveRouteBinding ($ value )
113115 {
114- return $ this ->repo ->where ($ this ->getRouteKeyName (), $ value )->first ();
116+ return $ this ->repository ->where ($ this ->getRouteKeyName (), $ value )->first ();
115117 }
116118
117119 /**
@@ -121,7 +123,7 @@ public function resolveRouteBinding($value)
121123 */
122124 public function jsonSerialize ()
123125 {
124- return $ this ->repo ->toArray ();
126+ return $ this ->repository ->toArray ();
125127 }
126128
127129 /**
@@ -131,6 +133,6 @@ public function jsonSerialize()
131133 */
132134 public function __toString ()
133135 {
134- return $ this ->repo ->toJson ();
136+ return $ this ->repository ->toJson ();
135137 }
136138}
0 commit comments