mgsmus
Söyle yaptım,
User.php ekledim // User Model
public function newCollection(array $models = [] )
{
return new UserCollection($models);
}
Bu da GroupNotification.php
<?php
namespace App\Notifications\Features;
use Illuminate\Notifications\Notification;
class GroupNotification
{
protected $notifiables;
protected $notification;
public function __construct(array $notifiables, Notification $notification)
{
$this->notifiables = collect($notifiables);
$this->notification = $notification;
}
public function __destruct()
{
$this->notifiables->each(function ($notifiable){
$this->notify($notifiable);
});
}
public function notify($notifiable)
{
$notifiable->notify($this->notification);
}
}
Bu da UserCollection.php // CustomUserCollection
<?php
namespace App\Collections;
use App\Notifications\Features\GroupNotification;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Collection;
class UserCollection extends Collection
{
public function notify(Notification $notification)
{
return new GroupNotification(
$this->items, $notification
);
}
}