@@ -530,7 +530,7 @@ public function push()
530
530
*/
531
531
public function save (array $ options = [])
532
532
{
533
- $ query = $ this ->newUneagerQueryWithoutScopes ();
533
+ $ query = $ this ->newModelQuery ();
534
534
535
535
// If the "saving" event returns false we'll bail out of the save and return
536
536
// false, indicating that the save failed. This provides a chance for any
@@ -815,7 +815,7 @@ public function forceDelete()
815
815
*/
816
816
protected function performDeleteOnModel ()
817
817
{
818
- $ this ->setKeysForSaveQuery ($ this ->newUneagerQueryWithoutScopes ())->delete ();
818
+ $ this ->setKeysForSaveQuery ($ this ->newModelQuery ())->delete ();
819
819
820
820
$ this ->exists = false ;
821
821
}
@@ -840,6 +840,18 @@ public function newQuery()
840
840
return $ this ->registerGlobalScopes ($ this ->newQueryWithoutScopes ());
841
841
}
842
842
843
+ /**
844
+ * Get a new query builder that doesn't have any global scopes or eager loading.
845
+ *
846
+ * @return \Illuminate\Database\Eloquent\Builder|static
847
+ */
848
+ public function newModelQuery ()
849
+ {
850
+ return $ this ->newEloquentBuilder (
851
+ $ this ->newBaseQueryBuilder ()
852
+ )->setModel ($ this );
853
+ }
854
+
843
855
/**
844
856
* Get a new query builder with no relationships loaded.
845
857
*
@@ -874,26 +886,11 @@ public function registerGlobalScopes($builder)
874
886
*/
875
887
public function newQueryWithoutScopes ()
876
888
{
877
- return $ this ->newUneagerQueryWithoutScopes ()
889
+ return $ this ->newModelQuery ()
878
890
->with ($ this ->with )
879
891
->withCount ($ this ->withCount );
880
892
}
881
893
882
- /**
883
- * Get a new query builder that doesn't have any global scopes or eager loading.
884
- *
885
- * @return \Illuminate\Database\Eloquent\Builder|static
886
- */
887
- public function newUneagerQueryWithoutScopes ()
888
- {
889
- $ builder = $ this ->newEloquentBuilder ($ this ->newBaseQueryBuilder ());
890
-
891
- // Once we have the query builders, we will set the model instances so the
892
- // builder can easily access any information it may need from the model
893
- // while it is constructing and executing various queries against it.
894
- return $ builder ->setModel ($ this );
895
- }
896
-
897
894
/**
898
895
* Get a new query instance without a given scope.
899
896
*
@@ -902,9 +899,7 @@ public function newUneagerQueryWithoutScopes()
902
899
*/
903
900
public function newQueryWithoutScope ($ scope )
904
901
{
905
- $ builder = $ this ->newQuery ();
906
-
907
- return $ builder ->withoutGlobalScope ($ scope );
902
+ return $ this ->newQuery ()->withoutGlobalScope ($ scope );
908
903
}
909
904
910
905
/**
0 commit comments