diff --git a/app/Events/AddMembership.php b/app/Events/AddMembership.php new file mode 100644 index 0000000..13dab23 --- /dev/null +++ b/app/Events/AddMembership.php @@ -0,0 +1,29 @@ +membership = $membership; + } + +} diff --git a/app/Jobs/FolderAddEntity.php b/app/Jobs/FolderAddEntity.php index 11b30c9..ab3a7e2 100644 --- a/app/Jobs/FolderAddEntity.php +++ b/app/Jobs/FolderAddEntity.php @@ -47,8 +47,10 @@ public function handle(): void { $federationMembershipId = Membership::select('federation_id') ->where('entity_id', $this->entity->id) + ->where('approved', 1) ->get(); + $diskName = config('storageCfg.name'); foreach ($federationMembershipId as $fedId) { diff --git a/app/Listeners/SendNewMemberToSaveJob.php b/app/Listeners/SendNewMemberToSaveJob.php new file mode 100644 index 0000000..7092bdd --- /dev/null +++ b/app/Listeners/SendNewMemberToSaveJob.php @@ -0,0 +1,37 @@ +membership->entity_id; + $entity = Entity::find($entityId); + + + if ($entity->approved == 1 && $event->membership->approved == 1 ) { + Log::info(" dispatch FolderAddEntity from Listener SendNewMemberToSaveJob"); + } + + } +} diff --git a/app/Models/Membership.php b/app/Models/Membership.php index 9585666..f8cfed8 100644 --- a/app/Models/Membership.php +++ b/app/Models/Membership.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\Events\AddMembership; use Illuminate\Database\Eloquent\Relations\Pivot; class Membership extends Pivot @@ -31,4 +32,11 @@ public function approver() { return $this->belongsTo('App\Models\User', 'approved_by'); } + + protected $dispatchesEvents = [ + 'updated' => AddMembership::class, + // 'deleted' => DeleteEntity::class, + + ]; + } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index b07c157..9582197 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use App\Events\AddMembership; use App\Events\CreateEntity; use App\Events\DeleteEntity; use App\Events\FederationApprove; @@ -9,6 +10,7 @@ use App\Listeners\CreateFederationFolder; use App\Listeners\SendCreatedEntityToSaveJob; use App\Listeners\SendDeletedEntityToDeleteJob; +use App\Listeners\SendNewMemberToSaveJob; use App\Listeners\SendUpdatedEntityToSaveJob; use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Listeners\SendEmailVerificationNotification; @@ -38,6 +40,9 @@ class EventServiceProvider extends ServiceProvider DeleteEntity::class => [ SendDeletedEntityToDeleteJob::class, ], + AddMembership::class => [ + SendNewMemberToSaveJob::class, + ], ];