Skip to content

Commit

Permalink
Merge pull request #31 from esensi/0.6-soft-delete-fix
Browse files Browse the repository at this point in the history
Fix Issue #30
  • Loading branch information
Daniel LaBarge committed Jun 8, 2016
2 parents 33fe8ce + 47e9168 commit 6bc8a8d
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ return Config::create()
'not_operator_with_space' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
'phpdoc_var_to_type' => true,
'phpdoc_type_to_var' => true,
'psr0' => false,
'short_array_syntax' => true,
'unalign_double_arrow' => false,
Expand Down
19 changes: 0 additions & 19 deletions src/Contracts/SoftDeletingModelInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
*/
interface SoftDeletingModelInterface
{
/**
* Boot the soft deleting trait for a model.
*/
public static function bootSoftDeletingTrait();

/**
* Force a hard delete on a soft deleted model.
*/
Expand All @@ -37,20 +32,6 @@ public function restore();
*/
public function trashed();

/**
* Get a new query builder that includes soft deletes.
*
* @return Illuminate\Database\Eloquent\Builder|static
*/
public static function withTrashed();

/**
* Get a new query builder that only includes soft deletes.
*
* @return Illuminate\Database\Eloquent\Builder|static
*/
public static function onlyTrashed();

/**
* Register a restoring model event with the dispatcher.
*
Expand Down
18 changes: 9 additions & 9 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ abstract class Model extends Eloquent implements
/**
* The attributes that should be mutated to dates.
*
* @type array
* @var array
*/
protected $dates = [];

/**
* The default rules that the model will validate against.
*
* @type array
* @var array
*/
protected $rules = [];

Expand All @@ -109,50 +109,50 @@ abstract class Model extends Eloquent implements
*
* @deprecated watson/validating 0.10.9
*
* @type array
* @var array
*/
protected $rulesets = [];

/**
* The attributes to encrypt when set and
* decrypt when gotten.
*
* @type array
* @var array
*/
protected $encryptable = [];

/**
* The attributes to hash before saving.
*
* @type array
* @var array
*/
protected $hashable = [];

/**
* Attributes to cast to a different type.
*
* @type array
* @var array
*/
protected $jugglable = [];

/**
* The attributes to purge before saving.
*
* @type array
* @var array
*/
protected $purgeable = [];

/**
* Relationships that the model should set up.
*
* @type array
* @var array
*/
protected $relationships = [];

/**
* Extra attributes to be added to pivot relationships.
*
* @type array
* @var array
*/
protected $relationshipPivots = [];

Expand Down
4 changes: 2 additions & 2 deletions src/Traits/EncryptingModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ trait EncryptingModelTrait
/**
* Whether the model is encrypting or not.
*
* @type bool
* @var bool
*/
protected $encrypting = true;

/**
* The Encrypter to use for encryption.
*
* @type Illuminate\Encryption\Encrypter
* @var Illuminate\Encryption\Encrypter
*/
protected $encrypter;

Expand Down
10 changes: 5 additions & 5 deletions src/Traits/HashingModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ trait HashingModelTrait
/**
* Whether the model is hashing or not.
*
* @type bool
* @var bool
*/
protected $hashing = true;

/**
* The Hasher to use for hashing.
*
* @type Illuminate\Contracts\Hashing\Hasher
* @var Illuminate\Contracts\Hashing\Hasher
*/
protected $hasher;

Expand Down Expand Up @@ -162,7 +162,7 @@ public function isHashed($attribute)
return false;
}

$info = password_get_info($this->attributes[ $attribute ]);
$info = password_get_info($this->attributes[$attribute]);

return (bool) ($info['algo'] !== 0);
}
Expand Down Expand Up @@ -213,11 +213,11 @@ public function checkHash($value, $hash)
public function setHashingAttribute($attribute, $value)
{
// Set the value which is presumably plain text
$this->attributes[ $attribute ] = $value;
$this->attributes[$attribute] = $value;

// Do the hashing if it needs it
if ( ! empty($value) && ($this->isDirty($attribute) || ! $this->isHashed($attribute))) {
$this->attributes[ $attribute ] = $this->hash($value);
$this->attributes[$attribute] = $this->hash($value);
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/Traits/JugglingModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ trait JugglingModelTrait
/**
* Whether the model is type juggling attributes or not.
*
* @type bool
* @var bool
*/
protected $juggling = true;

Expand Down Expand Up @@ -53,7 +53,7 @@ public function __set($key, $value)
parent::__set($key, $value);

// Dynamically set the juggled value
$this->setDynamicJuggle($key, $this->attribute[ $key ]);
$this->setDynamicJuggle($key, $this->attribute[$key]);
}

/**
Expand Down Expand Up @@ -320,7 +320,7 @@ public function getJuggleType($attribute)
{
$jugglable = $this->getJugglable();

return $jugglable[ $attribute ];
return $jugglable[$attribute];
}

/**
Expand All @@ -331,8 +331,8 @@ public function juggleAttributes()
// Iterate the juggable fields, and if the field is present
// cast the attribute and replace within the attributes array.
foreach ($this->getJugglable() as $attribute => $type) {
if (isset($this->attributes[ $attribute ])) {
$this->juggleAttribute($attribute, $this->attributes[ $attribute ]);
if (isset($this->attributes[$attribute])) {
$this->juggleAttribute($attribute, $this->attributes[$attribute]);
}
}
}
Expand All @@ -347,7 +347,7 @@ public function juggleAttributes()
public function juggleAttribute($attribute, $value)
{
$type = $this->getJuggleType($attribute);
$this->attributes[ $attribute ] = $this->juggle($value, $type);
$this->attributes[$attribute] = $this->juggle($value, $type);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/PurgingModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trait PurgingModelTrait
/**
* Whether the model is purging or not.
*
* @type bool
* @var bool
*/
protected $purging = true;

Expand Down
4 changes: 2 additions & 2 deletions src/Traits/RelatingModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function getRelationship($name)
throw $exception;
}

return $this->relationships[ $name ];
return $this->relationships[$name];
}

/**
Expand All @@ -132,7 +132,7 @@ public function getRelationship($name)
*/
public function getPivotAttributes($name)
{
return $this->relationshipPivots[ $name ] ?: [];
return $this->relationshipPivots[$name] ?: [];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/SoftDeletingModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trait SoftDeletingModelTrait
* We want to boot our own observer so we stub out this
* boot method. This renders this function void.
*/
public static function bootSoftDeletingTrait()
public static function bootSoftDeletes()
{
}

Expand Down
2 changes: 1 addition & 1 deletion tests/EncryptingModelTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ class ModelEncryptingStub extends Model
* The attributes to encrypt when set and
* decrypt when gotten.
*
* @type array
* @var array
*/
protected $encryptable = ['foo'];

Expand Down
2 changes: 1 addition & 1 deletion tests/HashingModelTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ class ModelHashingStub extends Model
/**
* The attributes to hash before saving.
*
* @type array
* @var array
*/
protected $hashable = ['foo'];

Expand Down
6 changes: 3 additions & 3 deletions tests/JugglingModelTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,14 @@ class ModelJugglingStub extends Model
/**
* Indicates if the model exists.
*
* @type bool
* @var bool
*/
public $exists = false;

/**
* The attributes to type juggle.
*
* @type array
* @var array
*/
protected $jugglable = [
'myString' => 'string',
Expand All @@ -597,7 +597,7 @@ class ModelJugglingStub extends Model
* in the tests to set the attributes in the object.
* Make sure the keys align with $jugglabe property on this stub.
*
* @type array
* @var array
*/
public $tmpAttributes = [
'myString' => 'Hello world',
Expand Down
2 changes: 1 addition & 1 deletion tests/PurgingModelTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ class ModelPurgingStub extends Model
/**
* The attributes to purge before saving.
*
* @type array
* @var array
*/
protected $purgeable = ['foo'];
}
8 changes: 4 additions & 4 deletions tests/RelatingModelTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@ class ModelRelatingStub extends Model
/**
* Indicates if the model exists.
*
* @type bool
* @var bool
*/
public $exists = false;

/**
* Relationships that the model should set up.
*
* @type array
* @var array
*/
protected $relationships = [

Expand All @@ -199,7 +199,7 @@ class ModelRelatingStub extends Model
/**
* Extra attributes to be added to pivot relationships.
*
* @type array
* @var array
*/
protected $relationshipPivots = [

Expand All @@ -215,7 +215,7 @@ class FooModelStub extends Model
/**
* Relationships that the model should set up.
*
* @type array
* @var array
*/
protected $relationships = [

Expand Down
2 changes: 1 addition & 1 deletion tests/SoftModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class SoftModelStub extends SoftModel
/**
* The attributes that should be mutated to dates.
*
* @type array
* @var array
*/
protected $dates = ['foo'];
}

0 comments on commit 6bc8a8d

Please sign in to comment.