src/Models/Manager.php
public function setTenantsAttribute($tenants): void
    {
        static::saved(function (self $model) use ($tenants) {
            $tenants = collect($tenants)->filter();

            $model->tenants->pluck('id')->similar($tenants)
            || activity()
                ->performedOn($model)
                ->withProperties(['attributes' => ['tenants' => $tenants], 'old' => ['tenants' => $model->tenants->pluck('id')->toArray()]])
                ->log('updated');

            $model->syncTenants($tenants);
        });
    }
public function setTenantsAttribute($tenants): void
    {
        static::saved(function (self $model) use ($tenants) {
            $tenants = collect($tenants)->filter();

            $model->tenants->pluck('id')->similar($tenants)
            || activity()
                ->performedOn($model)
                ->withProperties(['attributes' => ['tenants' => $tenants], 'old' => ['tenants' => $model->tenants->pluck('id')->toArray()]])
                ->log('updated');

            $model->syncTenants($tenants);
        });
    }
public function setTenantsAttribute ( $ tenants ) : void { static :: saved ( function ( self $ model ) use ( $ tenants ) { $ tenants = collect ( $ tenants ) -> filter ( ) ; $ model -> tenants -> pluck ( 'id' ) -> similar ( $ tenants ) || activity ( ) -> performedOn ( $ model ) -> withProperties ( [ 'attributes' => [ 'tenants' => $ tenants ] , 'old' => [ 'tenants' => $ model -> tenants -> pluck ( 'id' ) -> toArray ( ) ] ] ) -> log ( 'updated' ) ; $ model -> syncTenants ( $ tenants ) ; } ) ; }
Attach the given tenants to the model.

@param mixed $tenants

@return void
Attach the given tenants to the model .