Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Database/Attach/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Storage;
use Response;
use File as FileHelper;
use Illuminate\Support\Arr;
use October\Rain\Database\Model;
use October\Rain\Resize\Resizer;
use Symfony\Component\HttpFoundation\File\UploadedFile;
Expand Down Expand Up @@ -327,7 +328,7 @@ public function output($disposition = 'inline', $returnResponse = true)
*/
public function outputThumb($width, $height, $options = [], $returnResponse = true)
{
$disposition = array_get($options, 'disposition', 'inline');
$disposition = Arr::get($options, 'disposition', 'inline');
$options = $this->getDefaultThumbOptions($options);

// Generate thumb if not existing already
Expand Down
5 changes: 3 additions & 2 deletions src/Database/Models/DeferredBinding.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Event;
use Carbon\Carbon;
use Illuminate\Support\Arr;
use October\Rain\Database\Model;
use Throwable;

Expand Down Expand Up @@ -209,12 +210,12 @@ protected function deleteSlaveRecord()
}

$options = $masterObject->getRelationDefinition($this->master_field);
if (!array_get($options, 'delete', false)) {
if (!Arr::get($options, 'delete', false)) {
return;
}

// Only delete it if the relationship is null
$foreignKey = array_get($options, 'key', $masterObject->getForeignKey());
$foreignKey = Arr::get($options, 'key', $masterObject->getForeignKey());
if ($foreignKey && !$relatedObj->$foreignKey) {
$relatedObj->delete();
}
Expand Down
5 changes: 3 additions & 2 deletions src/Database/Relations/AttachOneOrMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Arr;
use October\Rain\Database\Attach\File as FileModel;
use Symfony\Component\HttpFoundation\File\UploadedFile;

Expand Down Expand Up @@ -368,7 +369,7 @@ public function remove(Model $model, $sessionKey = null)

$options = $this->parent->getRelationDefinition($this->relationName);

if (array_get($options, 'delete', false)) {
if (Arr::get($options, 'delete', false)) {
$model->delete();
}
else {
Expand Down Expand Up @@ -477,7 +478,7 @@ protected function ensureRelationIsEmpty()
{
$options = $this->parent->getRelationDefinition($this->relationName);

if (array_get($options, 'delete', false)) {
if (Arr::get($options, 'delete', false)) {
$this->delete();
}
else {
Expand Down
19 changes: 10 additions & 9 deletions src/Database/Relations/DefinedConstraints.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php namespace October\Rain\Database\Relations;

use Illuminate\Database\Eloquent\Relations\BelongsToMany as BelongsToManyBase;
use Illuminate\Support\Arr;

/**
* DefinedConstraints handles the constraints and filters defined by a relation
Expand Down Expand Up @@ -33,28 +34,28 @@ public function addDefinedConstraintsToRelation($relation, ?array $args = null)
}

// Default models (belongsTo, hasOne, hasOneThrough, morphOne)
if ($defaultData = array_get($args, 'default')) {
if ($defaultData = Arr::get($args, 'default')) {
$relation->withDefault($defaultData);
}

// Pivot data (belongsToMany, morphToMany, morphByMany)
if ($pivotData = array_get($args, 'pivot')) {
if ($pivotData = Arr::get($args, 'pivot')) {
$relation->withPivot($pivotData);
}

// Pivot incrementing key (belongsToMany, morphToMany, morphByMany)
if ($pivotKey = array_get($args, 'pivotKey')) {
if ($pivotKey = Arr::get($args, 'pivotKey')) {
$relation->withPivot($pivotKey);
}

// Pivot timestamps (belongsToMany, morphToMany, morphByMany)
if (array_get($args, 'timestamps')) {
if (Arr::get($args, 'timestamps')) {
$relation->withTimestamps();
}

// Count "helper" relation
// @deprecated use Laravel withCount() method instead
if (array_get($args, 'count')) {
if (Arr::get($args, 'count')) {
if ($relation instanceof BelongsToManyBase) {
$relation->countMode = true;
$keyName = $relation->getQualifiedForeignPivotKeyName();
Expand All @@ -79,14 +80,14 @@ public function addDefinedConstraintsToQuery($query, ?array $args = null)
}

// Conditions
if ($conditions = array_get($args, 'conditions')) {
if ($conditions = Arr::get($args, 'conditions')) {
$query->whereRaw($conditions);
}

// Sort order
// @deprecated count is deprecated
$hasCountArg = array_get($args, 'count') !== null;
if (($orderBy = array_get($args, 'order')) && !$hasCountArg) {
$hasCountArg = Arr::get($args, 'count') !== null;
if (($orderBy = Arr::get($args, 'order')) && !$hasCountArg) {
if (!is_array($orderBy)) {
$orderBy = [$orderBy];
}
Expand All @@ -105,7 +106,7 @@ public function addDefinedConstraintsToQuery($query, ?array $args = null)
}

// Scope
if ($scope = array_get($args, 'scope')) {
if ($scope = Arr::get($args, 'scope')) {
if (is_string($scope)) {
$query->$scope($this->parent);
}
Expand Down
5 changes: 3 additions & 2 deletions src/Database/Relations/HasOneOrMany.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php namespace October\Rain\Database\Relations;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;

/**
* HasOneOrMany
Expand Down Expand Up @@ -253,7 +254,7 @@ public function remove(Model $model, $sessionKey = null)
$options = $this->parent->getRelationDefinition($this->relationName);

// Delete or orphan the model
if (array_get($options, 'delete', false)) {
if (Arr::get($options, 'delete', false)) {
$model->delete();
}
else {
Expand Down Expand Up @@ -304,7 +305,7 @@ protected function ensureRelationIsEmpty()
{
$options = $this->parent->getRelationDefinition($this->relationName);

if (array_get($options, 'delete', false)) {
if (Arr::get($options, 'delete', false)) {
$this->delete();
}
else {
Expand Down
5 changes: 3 additions & 2 deletions src/Database/Relations/MorphOneOrMany.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php namespace October\Rain\Database\Relations;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;

/**
* MorphOneOrMany
Expand Down Expand Up @@ -244,7 +245,7 @@ public function remove(Model $model, $sessionKey = null)
$options = $this->parent->getRelationDefinition($this->relationName);

// Delete or orphan the model
if (array_get($options, 'delete', false)) {
if (Arr::get($options, 'delete', false)) {
$model->delete();
}
else {
Expand Down Expand Up @@ -298,7 +299,7 @@ protected function ensureRelationIsEmpty()
{
$options = $this->parent->getRelationDefinition($this->relationName);

if (array_get($options, 'delete', false)) {
if (Arr::get($options, 'delete', false)) {
$this->delete();
}
else {
Expand Down
5 changes: 3 additions & 2 deletions src/Database/Traits/Encryptable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Crypt;
use Exception;
use Illuminate\Support\Arr;

/**
* Encryptable database trait
Expand Down Expand Up @@ -49,8 +50,8 @@ public function initializeEncryptable()
$this->bindEvent('model.beforeGetAttribute', function ($key) {
if (
in_array($key, $this->getEncryptableAttributes()) &&
array_get($this->attributes, $key) !== null &&
array_get($this->attributes, $key) !== ''
Arr::get($this->attributes, $key) !== null &&
Arr::get($this->attributes, $key) !== ''
) {
return $this->getEncryptableValue($key);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Database/Traits/Multisite.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace October\Rain\Database\Traits;

use Illuminate\Support\Arr;
use Site;
use October\Rain\Database\Scopes\MultisiteScope;
use Exception;
Expand Down Expand Up @@ -331,7 +332,7 @@ public function getMultisiteConfig($key, $default = null)
return $default;
}

return array_get($this->propagatableSync, $key, $default);
return Arr::get($this->propagatableSync, $key, $default);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Database/Traits/Revisionable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Exception;
use DateTime;
use Illuminate\Database\Eloquent\Model as EloquentModel;
use Illuminate\Support\Arr;

/**
* Revisionable trait tracks changes to specific attributes
Expand Down Expand Up @@ -79,7 +80,7 @@ public function revisionableAfterUpdate()

$toSave[] = [
'field' => $attribute,
'old_value' => array_get($this->original, $attribute),
'old_value' => Arr::get($this->original, $attribute),
'new_value' => $value,
'revisionable_type' => $relationObject->getMorphClass(),
'revisionable_id' => $this->getKey(),
Expand Down
3 changes: 2 additions & 1 deletion src/Database/Traits/SimpleTree.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace October\Rain\Database\Traits;

use Illuminate\Support\Arr;
use October\Rain\Database\Collection;
use October\Rain\Database\TreeCollection;
use Exception;
Expand Down Expand Up @@ -228,7 +229,7 @@ public function scopeListsNested($query, $column, $key = null, $indent = '&nbsp;
}

// Add the children
$childItems = array_get($map, $item->{$idName}, []);
$childItems = Arr::get($map, $item->{$idName}, []);
if (count($childItems) > 0) {
$result = $result + $buildCollection($childItems, $map, $depth + 1);
}
Expand Down
5 changes: 3 additions & 2 deletions src/Database/Traits/SoftDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Database\Eloquent\Model as EloquentModel;
use Illuminate\Database\Eloquent\Collection as CollectionBase;
use Illuminate\Support\Arr;
use October\Rain\Database\Scopes\SoftDeleteScope;

/**
Expand Down Expand Up @@ -129,7 +130,7 @@ protected function performSoftDeleteOnRelations()
$definitions = $this->getRelationDefinitions();
foreach ($definitions as $type => $relations) {
foreach ($relations as $name => $options) {
if (!array_get($options, 'softDelete', false)) {
if (!Arr::get($options, 'softDelete', false)) {
continue;
}

Expand Down Expand Up @@ -213,7 +214,7 @@ protected function performRestoreOnRelations()
$definitions = $this->getRelationDefinitions();
foreach ($definitions as $type => $relations) {
foreach ($relations as $name => $options) {
if (!array_get($options, 'softDelete', false)) {
if (!Arr::get($options, 'softDelete', false)) {
continue;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Halcyon/Builder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php namespace October\Rain\Halcyon;

use Carbon\Carbon;
use Illuminate\Support\Arr;
use October\Rain\Halcyon\Exception\InvalidDirectoryNameException;
use October\Rain\Halcyon\Exception\InvalidExtensionException;
use October\Rain\Halcyon\Exception\MissingFileNameException;
Expand Down Expand Up @@ -645,7 +646,7 @@ protected function isCacheBusted($result)
return false;
}

$mtime = $result ? array_get(reset($result), 'mtime') : null;
$mtime = $result ? Arr::get(reset($result), 'mtime') : null;

list($name, $extension) = $this->selectSingle;

Expand Down
3 changes: 2 additions & 1 deletion src/Halcyon/Datasource/AutoDatasource.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace October\Rain\Halcyon\Datasource;

use Illuminate\Support\Arr;
use October\Rain\Halcyon\Model;
use October\Rain\Halcyon\Processors\Processor;

Expand Down Expand Up @@ -28,7 +29,7 @@ public function __construct(array $datasources)
{
$this->datasources = $datasources;

$this->primaryDatasource = array_first($datasources);
$this->primaryDatasource = Arr::first($datasources);

$this->postProcessor = new Processor;
}
Expand Down
9 changes: 5 additions & 4 deletions src/Halcyon/Processors/Processor.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace October\Rain\Halcyon\Processors;

use Illuminate\Support\Arr;
use October\Rain\Halcyon\Builder;

/**
Expand All @@ -24,7 +25,7 @@ public function processSelectOne(Builder $query, $result)
return null;
}

$fileName = array_get($result, 'fileName');
$fileName = Arr::get($result, 'fileName');

return [$fileName => $this->parseTemplateContent($query, $result, $fileName)];
}
Expand All @@ -45,7 +46,7 @@ public function processSelect(Builder $query, $results)
$items = [];

foreach ($results as $result) {
$fileName = array_get($result, 'fileName');
$fileName = Arr::get($result, 'fileName');
$items[$fileName] = $this->parseTemplateContent($query, $result, $fileName);
}

Expand All @@ -64,14 +65,14 @@ protected function parseTemplateContent($query, $result, $fileName)
'isCompoundObject' => $query->getModel()->isCompoundObject()
];

$content = array_get($result, 'content');
$content = Arr::get($result, 'content');

$processed = SectionParser::parse($content, $options);

return [
'fileName' => $fileName,
'content' => $content,
'mtime' => array_get($result, 'mtime'),
'mtime' => Arr::get($result, 'mtime'),
'markup' => $processed['markup'],
'code' => $processed['code']
] + $processed['settings'];
Expand Down
7 changes: 4 additions & 3 deletions src/Halcyon/Traits/Validation.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php namespace October\Rain\Halcyon\Traits;

use Validator;
use Illuminate\Support\Arr;
use Illuminate\Support\MessageBag;
use October\Rain\Support\Facades\Input;
use October\Rain\Halcyon\Exception\ModelException;
use October\Rain\Support\Facades\Input;
use Validator;
use Exception;

trait Validation
Expand Down Expand Up @@ -57,7 +58,7 @@ public static function bootValidation()
// If forcing the save event, the beforeValidate/afterValidate
// events should still fire for consistency. So validate an
// empty set of rules and messages.
$force = array_get($options, 'force', false);
$force = Arr::get($options, 'force', false);
if ($force) {
$valid = $model->validate([], []);
}
Expand Down
Loading