알림 템플릿 및 다중 알림 채널을 사용하여 사용자에게 알림을 보냅니다. 매크로가 포함된 Filament Native 알림 서비스를 지원하고 FCM 서비스 작업자 알림에 대한 전체 통합이 가능합니다.
사용자에게 알림 보내기
필라멘트 기본 알림 사용
알림 템플릿 사용
전체 FCM 서비스 워커 통합
여러 알림 채널 사용
알림을 받기 위한 API
알림 리소스 숨기기
Slack 드라이버 사용
디스코드 드라이버 사용
리버브 드라이버 사용
SMS Misr 드라이버 사용
이메일 드라이버 사용
데이터베이스 드라이버 사용
MessageBird 드라이버 사용
이 패키지를 사용하기 전에 설치했는지 확인하십시오
필라멘트 스파티 번역 가능
필라멘트 Spatie 미디어 라이브러리
필라멘트 설정 허브
작곡가는 토마토 PHP/필라멘트 경고가 필요합니다
이제 설정 테이블을 게시하고 마이그레이션해야 합니다.
php artisan Vendor:publish --provider="SpatieLaravelSettingsLaravelSettingsServiceProvider" --tag="migrations"
패키지를 설치한 후 이 명령을 실행하세요.
PHP artisan 필라멘트 경고:설치
이 패키지를 플러그인으로 사용하지 않는 경우 /app/Providers/Filament/AdminPanelProvider.php
에 플러그인을 등록하세요.
->플러그인(TomatoPHPFilamentAlertsFilamentAlertsPlugin::make() )
알림을 받도록 모델을 설정하려면
<?phpnamespace AppModels;use IlluminateContractsAuthMustVerifyEmail;use IlluminateDatabaseEloquentFactoriesHasFactory;use IlluminateFoundationAuthUser as Authenticatable;use IlluminateNotificationsNotifying;use LaravelFortifyTwoFactorAuthenticatable;use LaravelJetstreamHasProfilePhoto;use LaravelSanctumHasApiTokens;use SpatiePermissionTraitsHasRoles;TomatoPHPFilamentAlertsTraitsInteractsWithNotifications;클래스 사용자 확장 Authenticatable{use HasApiTokens;use HasFactory;use HasProfilePhoto;use Notifying;use TwoFactorAuthenticatable;use HasRoles;use InteractsWithNotifications; ...
실시간 알림을 받으려면 FCM에 대한 설정을 지정해야 합니다.
알림은 대기열에서 실행되므로 알림을 보내려면 대기열 작업자를 실행해야 합니다.
PHP 장인 대기열:작업
필라멘트 기본 알림을 사용할 수 있으며 우리는 당신을 위해 몇 가지 macro
추가합니다.
FilamentNotificationsNotification;Notification::make('send') 사용 ->title('테스트 알림') ->body('테스트 알림입니다.') ->icon('heroicon-o-bell') ->color('성공') ->actions([FilamentNotificationsActionsAction::make('view') ->label('보기') ->url('https://google.com') ->markAsRead() ]) ->sendToDiscord(auth()->user()) ->sendToEmail(인증()->사용자()) ->방송(인증()->사용자()) ->sendToDatabase(auth()->user()) ->slack으로 보내기(인증()->사용자()) ->sendToFCM(인증()->사용자())
새 템플릿을 생성하려면 템플릿 CRUD를 사용할 수 있으며, 모든 단일 알림에서 템플릿 키를 사용하므로 템플릿 키가 고유한지 확인하세요.
알림을 보내려면 SendNotification::class 도우미를 사용해야 합니다.
SendNotification::make($template->providers) ->템플릿($템플릿->키) ->findTitle($matchesTitle) ->제목 바꾸기($titleFill) ->findBody($matchesBody) ->바디바디($titleBody) ->모델(사용자::클래스) ->id(사용자::first()->id) ->프라이버시('비공개') ->불();
여기서 $template
키로 템플릿에서 선택되고 $matchesTitle 및 $matchesBody는 템플릿을 대체할 일치 항목의 배열이고 $titleFill 및 $titleBody는 일치 항목을 대체할 값의 배열입니다.
다음과 같은 여러 알림 채널을 사용할 수 있습니다.
이메일
SMS
FCM
리버브
데이터 베이스
느슨하게
불화
다음과 같은 직접적인 사용자 방법으로 작업할 수 있습니다.
$user->notifySMSMisr(string $message);$user->notifyEmail(string $message, ?string $subject = null, ?string $url = null);$user->notifyFCMSDK(string $message, string $type= '웹', ?string $title=null, ?string $url=null, ?string $image=null, ?string $icon=null, ?array $data=[]);$user->notifyDB(string $message, ?string $title=null, ?string $url =null);$user->notifySlack(string $title,string $message=null,?string $url=null, ?string $image=null, ?string $webhook=null);$user->notifyDiscord(string $title,string $message=null,?string $url=null, ?string $image=null, ?string $webhook=null);
FCM 알림이 작동하도록 하려면 필라멘트 설정 허브를 설치하고 플러그인에서 설정 허브 사용을 허용해야 합니다.
->플러그인(TomatoPHPFilamentAlertsFilamentAlertsPlugin::make() ->useSettingsHub() ->FCM() 사용 )
이 명령을 사용하여 filament-fcm
패키지를 설치해야 합니다.
작곡가는 토마토 PHP/필라멘트-fcm이 필요합니다
서비스 제공업체 플러그인을 추가하세요.
->플러그인(TomatoPHPFilamentFcmFilamentFcmPlugin::make())
이제 구성을 업데이트해야 합니다
# Firebase ProjectFIREBASE_API_KEY=FIREBASE_AUTH_DOMAIN=FIREBASE_DATABASE_URL=FIREBASE_PROJECT_ID=FIREBASE_STORAGE_BUCKET=FIREBASE_MESSAGING_SENDER_ID=FIREBASE_APP_ID=FIREBASE_MEASUREMENT_ID=# Firebase 클라우드 메시징FIREBASE_VAPID=# Firebase Alert SoundFCM_ALERT_SOUND=
이 명령을 실행하는 것보다
php artisan 필라멘트-fcm:설치
백그라운드에서 알림이 작동하도록 FCM 작업자를 생성합니다.
사이드바에서 알림 리소스를 숨기려면 다음과 같은 플러그인 메소드 hideNotificationsResources
를 사용할 수 있습니다.
->플러그인(TomatoPHPFilamentAlertsFilamentAlertsPlugin::make() ->hideNotificationsResources() )
Slack 드라이버를 사용하려면 설정 허브에서 Slack Webhook을 설정하고 다음과 같은 플러그인 메소드 useSlack
사용해야 합니다.
->플러그인(TomatoPHPFilamentAlertsFilamentAlertsPlugin::make() ->슬랙() 사용 )
이제 .env
파일에 웹훅 URL과 함께 SLACK_WEBHOOK
키를 추가하세요.
불일치 드라이버를 사용하려면 설정 허브에서 불일치 웹훅을 설정하고 다음과 같은 플러그인 메소드 useDiscord
사용해야 합니다.
->플러그인(TomatoPHPFilamentAlertsFilamentAlertsPlugin::make() ->사용Discord() )
이제 .env
파일에 웹훅 URL과 함께 DISCORD_WEBHOOK
키를 추가하세요.
우리는 알림을 받고 api/notifications
경로에서 찾을 수 있는 몇 가지 작업을 수행하기 위한 일부 API를 지원합니다.
다음과 같은 플러그인 메소드 apiModel
사용하여 사용자 모델을 변경할 수 있습니다.
->플러그인(TomatoPHPFilamentAlertsFilamentAlertsPlugin::make() ->apiModel(사용자::클래스) )
이 명령을 사용하여 구성 파일을 게시할 수 있습니다
php artisan Vendor:publish --tag="필라멘트-alerts-config"
이 명령을 사용하여 뷰 파일을 게시할 수 있습니다
php artisan Vendor:publish --tag="필라멘트-alerts-views"
이 명령을 사용하여 언어 파일을 게시할 수 있습니다
php artisan Vendor:publish --tag="필라멘트-alerts-lang"
이 명령을 사용하여 마이그레이션 파일을 게시할 수 있습니다
php artisan Vendor:publish --tag="필라멘트-alerts-migrations"
우리의 멋진 TomatoPHP를 확인해 보세요