File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change 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
@@ -158,14 +155,20 @@ public function model() {
158155 * @throws PPSpaces\Exceptions\RepositoryException
159156 */
160157 public function initializeRepository () {
158+ // Loading application instance
159+ $ this ->app = app ();
160+
161+ // Making model
161162 $ model = $ this ->app ->make ($ this ->model );
162163
163164 if (!$ model instanceof Model) {
164165 throw new RepositoryException ("Class {$ this ->model } must be an instance of Illuminate \\Database \\Eloquent \\Model " );
165166 }
166167
168+ // Create repository model query
167169 $ this ->repository = $ model ->newQuery ();
168170
171+ // Inject before scope
169172 $ this ->before ($ this ->repository );
170173 }
171174
@@ -215,6 +218,6 @@ public function __toString()
215218 return $ this ->resolved ->toJson ();
216219 }
217220
218- return null ;
221+ return $ this -> get ()-> toJson () ;
219222 }
220223}
You can’t perform that action at this time.
0 commit comments