Skip to content

Commit

Permalink
Merge branch 'feature/laravel-6' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
chelout committed Sep 4, 2019
2 parents 16034f6 + a326986 commit b67dbdc
Show file tree
Hide file tree
Showing 37 changed files with 240 additions and 88 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ env:
matrix:
fast_finish: true
include:
- php: 7.1
- php: 7.1
env: setup=lowest
- php: 7.2
- php: 7.2
env: setup=lowest
- php: 7.3
- php: 7.3
env: setup=lowest
- php: 7.4
- php: 7.4
env: setup=lowest

sudo: false

Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
}
],
"require": {
"php": "^7.1.3",
"illuminate/container": "~5.8.0",
"illuminate/database": "~5.8.0",
"illuminate/events": "~5.8.0",
"illuminate/support": "~5.8.0"
"php": "^7.2",
"illuminate/container": "^6.0",
"illuminate/database": "^6.0",
"illuminate/events": "^6.0",
"illuminate/support": "^6.0"
},
"require-dev": {
"phpunit/phpunit": "~7.0|~8.0",
"orchestra/testbench": "3.8.*"
"phpunit/phpunit": "^8.3",
"orchestra/testbench-core": "^4.0",
"orchestra/testbench": "^4.0"
},
"autoload": {
"psr-4": {
Expand Down
8 changes: 7 additions & 1 deletion src/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

use Chelout\RelationshipEvents\Contracts\EventDispatcher;
use Chelout\RelationshipEvents\Traits\HasEventDispatcher;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo as BelongsToBase;

/**
* Class BelongsTo
*
* @package Chelout\RelationshipEvents
*
* @property-read \Chelout\RelationshipEvents\Concerns\HasBelongsToEvents $parent
*/
class BelongsTo extends BelongsToBase implements EventDispatcher
{
use HasEventDispatcher;
Expand Down
8 changes: 7 additions & 1 deletion src/BelongsToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

use Chelout\RelationshipEvents\Contracts\EventDispatcher;
use Chelout\RelationshipEvents\Traits\HasEventDispatcher;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany as BelongsToManyBase;

/**
* Class BelongsToMany
*
* @package Chelout\RelationshipEvents
*
* @property-read \Chelout\RelationshipEvents\Concerns\HasBelongsToManyEvents $parent
*/
class BelongsToMany extends BelongsToManyBase implements EventDispatcher
{
use HasEventDispatcher;
Expand Down
7 changes: 7 additions & 0 deletions src/Concerns/HasBelongsToEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
* Trait HasBelongsToEvents
*
* @package Chelout\RelationshipEvents\Concerns
*
* @mixin \Chelout\RelationshipEvents\Traits\HasDispatchableEvents
*/
trait HasBelongsToEvents
{
/**
Expand Down
7 changes: 7 additions & 0 deletions src/Concerns/HasBelongsToManyEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
* Trait HasBelongsToManyEvents
*
* @package Chelout\RelationshipEvents\Concerns
*
* @mixin \Chelout\RelationshipEvents\Traits\HasDispatchableEvents
*/
trait HasBelongsToManyEvents
{
/**
Expand Down
7 changes: 7 additions & 0 deletions src/Concerns/HasManyEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
* Trait HasManyEvents
*
* @package Chelout\RelationshipEvents\Concerns
*
* @mixin \Chelout\RelationshipEvents\Traits\HasDispatchableEvents
*/
trait HasManyEvents
{
/**
Expand Down
7 changes: 7 additions & 0 deletions src/Concerns/HasMorphManyEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
* Trait HasMorphManyEvents
*
* @package Chelout\RelationshipEvents\Concerns
*
* @mixin \Chelout\RelationshipEvents\Traits\HasDispatchableEvents
*/
trait HasMorphManyEvents
{
/**
Expand Down
7 changes: 7 additions & 0 deletions src/Concerns/HasMorphOneEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
* Trait HasMorphOneEvents
*
* @package Chelout\RelationshipEvents\Concerns
*
* @mixin \Chelout\RelationshipEvents\Traits\HasDispatchableEvents
*/
trait HasMorphOneEvents
{
/**
Expand Down
7 changes: 7 additions & 0 deletions src/Concerns/HasMorphToEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
* Trait HasMorphToEvents
*
* @package Chelout\RelationshipEvents\Concerns
*
* @mixin \Chelout\RelationshipEvents\Traits\HasDispatchableEvents
*/
trait HasMorphToEvents
{
/**
Expand Down
7 changes: 7 additions & 0 deletions src/Concerns/HasMorphToManyEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
* Trait HasMorphToManyEvents
*
* @package Chelout\RelationshipEvents\Concerns
*
* @mixin \Chelout\RelationshipEvents\Traits\HasDispatchableEvents
*/
trait HasMorphToManyEvents
{
/**
Expand Down
7 changes: 7 additions & 0 deletions src/Concerns/HasMorphedByManyEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
* Trait HasMorphedByManyEvents
*
* @package Chelout\RelationshipEvents\Concerns
*
* @mixin \Chelout\RelationshipEvents\Traits\HasDispatchableEvents
*/
trait HasMorphedByManyEvents
{
/**
Expand Down
7 changes: 7 additions & 0 deletions src/Concerns/HasOneEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
* Trait HasOneEvents
*
* @package Chelout\RelationshipEvents\Concerns
*
* @mixin \Chelout\RelationshipEvents\Traits\HasDispatchableEvents
*/
trait HasOneEvents
{
/**
Expand Down
5 changes: 5 additions & 0 deletions src/HasMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
use Chelout\RelationshipEvents\Traits\HasOneOrManyMethods;
use Illuminate\Database\Eloquent\Relations\HasMany as HasManyBase;

/**
* Class HasMany
*
* @package Chelout\RelationshipEvents
*/
class HasMany extends HasManyBase implements EventDispatcher
{
use HasEventDispatcher;
Expand Down
5 changes: 5 additions & 0 deletions src/HasOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
use Chelout\RelationshipEvents\Traits\HasOneOrManyMethods;
use Illuminate\Database\Eloquent\Relations\HasOne as HasOneBase;

/**
* Class HasOne
*
* @package Chelout\RelationshipEvents
*/
class HasOne extends HasOneBase implements EventDispatcher
{
use HasEventDispatcher;
Expand Down
5 changes: 5 additions & 0 deletions src/MorphMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphMany as MorphManyBase;

/**
* Class MorphMany
*
* @package Chelout\RelationshipEvents
*/
class MorphMany extends MorphManyBase implements EventDispatcher
{
use HasEventDispatcher;
Expand Down
5 changes: 5 additions & 0 deletions src/MorphOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
use Chelout\RelationshipEvents\Traits\HasOneOrManyMethods;
use Illuminate\Database\Eloquent\Relations\MorphOne as MorphOneBase;

/**
* Class MorphOne
*
* @package Chelout\RelationshipEvents
*/
class MorphOne extends MorphOneBase implements EventDispatcher
{
use HasEventDispatcher;
Expand Down
11 changes: 9 additions & 2 deletions src/MorphTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

use Chelout\RelationshipEvents\Contracts\EventDispatcher;
use Chelout\RelationshipEvents\Traits\HasEventDispatcher;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo as MorphToBase;

/**
* Class MorphTo
*
* @package Chelout\RelationshipEvents
*
* @property-read \Chelout\RelationshipEvents\Concerns\HasMorphToEvents $parent
*/
class MorphTo extends MorphToBase implements EventDispatcher
{
use HasEventDispatcher;
Expand Down Expand Up @@ -62,7 +68,8 @@ public function update(array $attributes)

$this->parent->fireModelMorphToEvent('updating', $this->relationName, $related);

if ($related && $result = $related->fill($attributes)->save()) {
$result = $related->fill($attributes)->save();
if ($related && $result) {
$this->parent->fireModelMorphToEvent('updated', $this->relationName, $related);
}

Expand Down
8 changes: 7 additions & 1 deletion src/MorphToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

use Chelout\RelationshipEvents\Contracts\EventDispatcher;
use Chelout\RelationshipEvents\Traits\HasEventDispatcher;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphToMany as MorphToManyBase;

/**
* Class MorphToMany
*
* @package Chelout\RelationshipEvents
*
* @property-read \Chelout\RelationshipEvents\Concerns\HasMorphToManyEvents $parent
*/
class MorphToMany extends MorphToManyBase implements EventDispatcher
{
use HasEventDispatcher;
Expand Down
8 changes: 7 additions & 1 deletion src/MorphedByMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

use Chelout\RelationshipEvents\Contracts\EventDispatcher;
use Chelout\RelationshipEvents\Traits\HasEventDispatcher;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphToMany as MorphToManyBase;

/**
* Class MorphedByMany
*
* @package Chelout\RelationshipEvents
*
* @property-read \Chelout\RelationshipEvents\Concerns\HasMorphedByManyEvents $parent
*/
class MorphedByMany extends MorphToManyBase implements EventDispatcher
{
use HasEventDispatcher;
Expand Down
5 changes: 5 additions & 0 deletions src/RelationshipEventsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

use Illuminate\Support\ServiceProvider;

/**
* Class RelationshipEventsServiceProvider
*
* @package Chelout\RelationshipEvents
*/
class RelationshipEventsServiceProvider extends ServiceProvider
{
/**
Expand Down
7 changes: 7 additions & 0 deletions src/Traits/HasDispatchableEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

namespace Chelout\RelationshipEvents\Traits;

/**
* Trait HasDispatchableEvents
*
* @package Chelout\RelationshipEvents\Traits
*
* @mixin \Illuminate\Database\Eloquent\Concerns\HasEvents
*/
trait HasDispatchableEvents
{
/**
Expand Down
5 changes: 5 additions & 0 deletions src/Traits/HasEventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

use Illuminate\Contracts\Events\Dispatcher;

/**
* Trait HasEventDispatcher
*
* @package Chelout\RelationshipEvents\Traits
*/
trait HasEventDispatcher
{
/**
Expand Down
9 changes: 8 additions & 1 deletion src/Traits/HasOneOrManyMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;

/**
* Trait HasOneOrManyMethods
*
* @package Chelout\RelationshipEvents\Traits
*
* @property-read \Illuminate\Database\Eloquent\Model $related
*/
trait HasOneOrManyMethods
{
/**
Expand All @@ -16,7 +23,7 @@ trait HasOneOrManyMethods
*/
public function create(array $attributes = [])
{
return tap($this->related->newInstance($attributes), function ($instance) {
return tap($this->related->newInstance($attributes), function (Model $instance) {
$this->fireModelRelationshipEvent('creating', $instance);

$this->setForeignAttributesForCreate($instance);
Expand Down
Loading

0 comments on commit b67dbdc

Please sign in to comment.