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

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

            $model->abilities()->sync($abilities, true);
        });
    }
public function setAbilitiesAttribute($abilities): void
    {
        static::saved(function (self $model) use ($abilities) {
            $abilities = collect($abilities)->filter();

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

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

@param mixed $abilities

@return void
Attach the given abilities to the model .