44
55use ReflectionClass ;
66
7- use Illuminate \Container \Container as App ;
8-
97use Illuminate \Database \Eloquent \Model ;
108use Illuminate \Contracts \Routing \UrlRoutable ;
119
@@ -57,9 +55,8 @@ abstract class Repository implements RepositoryContract, UrlRoutable
5755 * @param \Illuminate\Database\Eloquent\Model $model
5856 * @return void
5957 */
60- public function __construct (App $ app ) {
61- $ this ->app = $ app ;
62-
58+ public function __construct () {
59+ // Initialize Repository Instance
6360 $ this ->initializeRepository ();
6461 }
6562
@@ -69,7 +66,9 @@ public function __construct(App $app) {
6966 * @param \Illuminate\Database\Query\Builder $query
7067 * @return void
7168 */
72- abstract public function before ($ query );
69+ public function before ($ query ) {
70+ //
71+ }
7372
7473 /**
7574 * Get all of the models from the database.
@@ -139,7 +138,9 @@ public function delete($id) {
139138 * @param \Illuminate\Support\Collection|array|int $ids
140139 * @return int
141140 */
142- abstract static function destroy ($ ids );
141+ static function destroy ($ ids ) {
142+ //
143+ }
143144
144145 /**
145146 * Specify Model class name
@@ -158,14 +159,20 @@ public function model() {
158159 * @throws PPSpaces\Exceptions\RepositoryException
159160 */
160161 public function initializeRepository () {
162+ // Loading application instance
163+ $ this ->app = app ();
164+
165+ // Making model
161166 $ model = $ this ->app ->make ($ this ->model );
162167
163168 if (!$ model instanceof Model) {
164169 throw new RepositoryException ("Class {$ this ->model } must be an instance of Illuminate \\Database \\Eloquent \\Model " );
165170 }
166171
172+ // Create repository model query
167173 $ this ->repository = $ model ->newQuery ();
168174
175+ // Inject before scope
169176 $ this ->before ($ this ->repository );
170177 }
171178
@@ -215,6 +222,6 @@ public function __toString()
215222 return $ this ->resolved ->toJson ();
216223 }
217224
218- return null ;
225+ return $ this -> get ()-> toJson () ;
219226 }
220227}
0 commit comments