11<?php namespace October \Rain \Database \Relations ;
22
33use Illuminate \Database \Eloquent \Relations \BelongsToMany as BelongsToManyBase ;
4+ use Illuminate \Support \Arr ;
45
56/**
67 * DefinedConstraints handles the constraints and filters defined by a relation
@@ -33,28 +34,28 @@ public function addDefinedConstraintsToRelation($relation, ?array $args = null)
3334 }
3435
3536 // Default models (belongsTo, hasOne, hasOneThrough, morphOne)
36- if ($ defaultData = array_get ($ args , 'default ' )) {
37+ if ($ defaultData = Arr:: get ($ args , 'default ' )) {
3738 $ relation ->withDefault ($ defaultData );
3839 }
3940
4041 // Pivot data (belongsToMany, morphToMany, morphByMany)
41- if ($ pivotData = array_get ($ args , 'pivot ' )) {
42+ if ($ pivotData = Arr:: get ($ args , 'pivot ' )) {
4243 $ relation ->withPivot ($ pivotData );
4344 }
4445
4546 // Pivot incrementing key (belongsToMany, morphToMany, morphByMany)
46- if ($ pivotKey = array_get ($ args , 'pivotKey ' )) {
47+ if ($ pivotKey = Arr:: get ($ args , 'pivotKey ' )) {
4748 $ relation ->withPivot ($ pivotKey );
4849 }
4950
5051 // Pivot timestamps (belongsToMany, morphToMany, morphByMany)
51- if (array_get ($ args , 'timestamps ' )) {
52+ if (Arr:: get ($ args , 'timestamps ' )) {
5253 $ relation ->withTimestamps ();
5354 }
5455
5556 // Count "helper" relation
5657 // @deprecated use Laravel withCount() method instead
57- if (array_get ($ args , 'count ' )) {
58+ if (Arr:: get ($ args , 'count ' )) {
5859 if ($ relation instanceof BelongsToManyBase) {
5960 $ relation ->countMode = true ;
6061 $ keyName = $ relation ->getQualifiedForeignPivotKeyName ();
@@ -79,14 +80,14 @@ public function addDefinedConstraintsToQuery($query, ?array $args = null)
7980 }
8081
8182 // Conditions
82- if ($ conditions = array_get ($ args , 'conditions ' )) {
83+ if ($ conditions = Arr:: get ($ args , 'conditions ' )) {
8384 $ query ->whereRaw ($ conditions );
8485 }
8586
8687 // Sort order
8788 // @deprecated count is deprecated
88- $ hasCountArg = array_get ($ args , 'count ' ) !== null ;
89- if (($ orderBy = array_get ($ args , 'order ' )) && !$ hasCountArg ) {
89+ $ hasCountArg = Arr:: get ($ args , 'count ' ) !== null ;
90+ if (($ orderBy = Arr:: get ($ args , 'order ' )) && !$ hasCountArg ) {
9091 if (!is_array ($ orderBy )) {
9192 $ orderBy = [$ orderBy ];
9293 }
@@ -105,7 +106,7 @@ public function addDefinedConstraintsToQuery($query, ?array $args = null)
105106 }
106107
107108 // Scope
108- if ($ scope = array_get ($ args , 'scope ' )) {
109+ if ($ scope = Arr:: get ($ args , 'scope ' )) {
109110 if (is_string ($ scope )) {
110111 $ query ->$ scope ($ this ->parent );
111112 }
0 commit comments