| 1 | <?php |
| 2 | |
| 3 | namespace Illuminate\Support\Facades; |
| 4 | |
| 5 | use Illuminate\Notifications\AnonymousNotifiable; |
| 6 | use Illuminate\Notifications\ChannelManager; |
| 7 | use Illuminate\Support\Testing\Fakes\NotificationFake; |
| 8 | |
| 9 | /** |
| 10 | * @method static void send(\Illuminate\Support\Collection|mixed $notifiables, mixed $notification) |
| 11 | * @method static void sendNow(\Illuminate\Support\Collection|mixed $notifiables, mixed $notification, array|null $channels = null) |
| 12 | * @method static mixed channel(string|null $name = null) |
| 13 | * @method static string getDefaultDriver() |
| 14 | * @method static string deliversVia() |
| 15 | * @method static void deliverVia(string $channel) |
| 16 | * @method static \Illuminate\Notifications\ChannelManager locale(string $locale) |
| 17 | * @method static mixed driver(string|null $driver = null) |
| 18 | * @method static \Illuminate\Notifications\ChannelManager extend(string $driver, \Closure $callback) |
| 19 | * @method static array getDrivers() |
| 20 | * @method static \Illuminate\Contracts\Container\Container getContainer() |
| 21 | * @method static \Illuminate\Notifications\ChannelManager setContainer(\Illuminate\Contracts\Container\Container $container) |
| 22 | * @method static \Illuminate\Notifications\ChannelManager forgetDrivers() |
| 23 | * @method static void macro(string $name, object|callable $macro) |
| 24 | * @method static void mixin(object $mixin, bool $replace = true) |
| 25 | * @method static bool hasMacro(string $name) |
| 26 | * @method static void flushMacros() |
| 27 | * @method static void assertSentOnDemand(string|\Closure $notification, callable|null $callback = null) |
| 28 | * @method static void assertSentTo(mixed $notifiable, string|\Closure $notification, callable|null $callback = null) |
| 29 | * @method static void assertSentOnDemandTimes(string $notification, int $times = 1) |
| 30 | * @method static void assertSentToTimes(mixed $notifiable, string $notification, int $times = 1) |
| 31 | * @method static void assertNotSentTo(mixed $notifiable, string|\Closure $notification, callable|null $callback = null) |
| 32 | * @method static void assertNothingSent() |
| 33 | * @method static void assertNothingSentTo(mixed $notifiable) |
| 34 | * @method static void assertSentTimes(string $notification, int $expectedCount) |
| 35 | * @method static void assertCount(int $expectedCount) |
| 36 | * @method static \Illuminate\Support\Collection sent(mixed $notifiable, string $notification, callable|null $callback = null) |
| 37 | * @method static bool hasSent(mixed $notifiable, string $notification) |
| 38 | * @method static \Illuminate\Support\Testing\Fakes\NotificationFake serializeAndRestore(bool $serializeAndRestore = true) |
| 39 | * @method static array sentNotifications() |
| 40 | * |
| 41 | * @see \Illuminate\Notifications\ChannelManager |
| 42 | * @see \Illuminate\Support\Testing\Fakes\NotificationFake |
| 43 | */ |
| 44 | class Notification extends Facade |
| 45 | { |
| 46 | /** |
| 47 | * Replace the bound instance with a fake. |
| 48 | * |
| 49 | * @return \Illuminate\Support\Testing\Fakes\NotificationFake |
| 50 | */ |
| 51 | public static function fake() |
| 52 | { |
| 53 | return tap(new NotificationFake, function ($fake) { |
| 54 | static::swap($fake); |
| 55 | }); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Begin sending a notification to an anonymous notifiable on the given channels. |
| 60 | * |
| 61 | * @param array $channels |
| 62 | * @return \Illuminate\Notifications\AnonymousNotifiable |
| 63 | */ |
| 64 | public static function routes(array $channels) |
| 65 | { |
| 66 | $notifiable = new AnonymousNotifiable; |
| 67 | |
| 68 | foreach ($channels as $channel => $route) { |
| 69 | $notifiable->route($channel, $route); |
| 70 | } |
| 71 | |
| 72 | return $notifiable; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Begin sending a notification to an anonymous notifiable. |
| 77 | * |
| 78 | * @param string $channel |
| 79 | * @param mixed $route |
| 80 | * @return \Illuminate\Notifications\AnonymousNotifiable |
| 81 | */ |
| 82 | public static function route($channel, $route) |
| 83 | { |
| 84 | return (new AnonymousNotifiable)->route($channel, $route); |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Get the registered name of the component. |
| 89 | * |
| 90 | * @return string |
| 91 | */ |
| 92 | protected static function getFacadeAccessor() |
| 93 | { |
| 94 | return ChannelManager::class; |
| 95 | } |
| 96 | } |