Skip to content

Commit e603656

Browse files
committed
Merge branch 'develop'
2 parents 84c0424 + ac28125 commit e603656

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/Console/stubs/repository.model.stub

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class DummyClass extends Repository {
1212
*
1313
* @var \DummyFullModelClass
1414
*/
15-
protected $DummyModelVariable;
15+
protected $repo;
1616

1717
/**
1818
* Create a new repository instance.
@@ -21,7 +21,7 @@ class DummyClass extends Repository {
2121
* @return void
2222
*/
2323
public function __construct(DummyModelClass $DummyModelVariable) {
24-
$this->DummyModelVariable = $DummyModelVariable;
24+
$this->repo = $DummyModelVariable;
2525
}
2626

2727
/**
@@ -31,7 +31,7 @@ class DummyClass extends Repository {
3131
* @return \Illuminate\Database\Eloquent\Collection|static[]
3232
*/
3333
public function all($columns = ['*']) {
34-
// return $this->get($columns);
34+
return $this->get($columns);
3535
}
3636

3737
/**
@@ -41,7 +41,7 @@ class DummyClass extends Repository {
4141
* @return \DummyFullModelClass
4242
*/
4343
public function get($columns = ['*']) {
44-
// return $this->DummyModelVariable->get($columns);
44+
return $this->repo->get($columns);
4545
}
4646

4747
/**
@@ -51,7 +51,7 @@ class DummyClass extends Repository {
5151
* @return \DummyFullModelClass
5252
*/
5353
public function find($id) {
54-
// return $this->DummyModelVariable->findOrFail($id);
54+
// return $this->repo->findOrFail($id);
5555
}
5656

5757
/**
@@ -61,7 +61,7 @@ class DummyClass extends Repository {
6161
* @return bool
6262
*/
6363
public function create(array $attributes) {
64-
// return $this->DummyModelVariable->create($attributes);
64+
// return $this->repo->create($attributes);
6565
}
6666

6767
/**
@@ -72,7 +72,7 @@ class DummyClass extends Repository {
7272
* @return bool
7373
*/
7474
public function update(array $attributes = []) {
75-
// return $this->DummyModelVariable->update($attributes);
75+
// return $this->repo->update($attributes);
7676
}
7777

7878
/**
@@ -83,6 +83,6 @@ class DummyClass extends Repository {
8383
* @throws \Exception
8484
*/
8585
public function delete($id) {
86-
// return $this->DummyModelVariable->findOrFail($id)->delete();
86+
// return $this->repo->findOrFail($id)->delete();
8787
}
8888
}

src/Repositories/Model.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
abstract 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

Comments
 (0)