Skip to content

Commit

Permalink
Added the assignChannels method to the Channelable trait
Browse files Browse the repository at this point in the history
  • Loading branch information
fulopattila122 committed Sep 8, 2023
1 parent 602b910 commit ef7907e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Channel/Traits/Channelable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@

namespace Vanilo\Channel\Traits;

use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Support\Collection;
use Vanilo\Channel\Contracts\Channel;
use Vanilo\Channel\Models\ChannelProxy;

/**
* @property-read Collection $channels
* @property-read \Illuminate\Database\Eloquent\Collection $channels
*/
trait Channelable
{
Expand All @@ -38,4 +39,9 @@ public function isNotInChannel(Channel|int|string $channel): bool
{
return !$this->isInChannel($channel);
}

public function assignChannels(array|Model|Collection $channels): void
{
$this->channels()->sync($channels);
}
}

0 comments on commit ef7907e

Please sign in to comment.