Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions contracts/binding/binding.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
package binding

const (
Artisan = "goravel.artisan"
Auth = "goravel.auth"
Cache = "goravel.cache"
Config = "goravel.config"
Crypt = "goravel.crypt"
DB = "goravel.db"
Event = "goravel.event"
Gate = "goravel.gate"
Grpc = "goravel.grpc"
Hash = "goravel.hash"
Http = "goravel.http"
Lang = "goravel.lang"
Log = "goravel.log"
Mail = "goravel.mail"
Orm = "goravel.orm"
Process = "goravel.process"
Queue = "goravel.queue"
RateLimiter = "goravel.rate_limiter"
Route = "goravel.route"
Schedule = "goravel.schedule"
Schema = "goravel.schema"
Seeder = "goravel.seeder"
Session = "goravel.session"
Storage = "goravel.storage"
Testing = "goravel.testing"
Validation = "goravel.validation"
View = "goravel.view"
Artisan = "goravel.artisan"
Auth = "goravel.auth"
Cache = "goravel.cache"
Config = "goravel.config"
Crypt = "goravel.crypt"
DB = "goravel.db"
Event = "goravel.event"
Gate = "goravel.gate"
Grpc = "goravel.grpc"
Hash = "goravel.hash"
Http = "goravel.http"
Lang = "goravel.lang"
Log = "goravel.log"
Mail = "goravel.mail"
Orm = "goravel.orm"
Process = "goravel.process"
Queue = "goravel.queue"
RateLimiter = "goravel.rate_limiter"
Route = "goravel.route"
Schedule = "goravel.schedule"
Schema = "goravel.schema"
Seeder = "goravel.seeder"
Session = "goravel.session"
Storage = "goravel.storage"
Testing = "goravel.testing"
Validation = "goravel.validation"
View = "goravel.view"
Notification = "goravel.notification"
)

type Relationship struct {
Expand Down
110 changes: 56 additions & 54 deletions contracts/facades/facades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,63 @@ package facades
import "github.com/goravel/framework/contracts/binding"

const (
Artisan = "Artisan"
Auth = "Auth"
Cache = "Cache"
Config = "Config"
Crypt = "Crypt"
DB = "DB"
Event = "Event"
Gate = "Gate"
Grpc = "Grpc"
Hash = "Hash"
Http = "Http"
Lang = "Lang"
Log = "Log"
Mail = "Mail"
Process = "Process"
Orm = "Orm"
Queue = "Queue"
RateLimiter = "RateLimiter"
Route = "Route"
Schedule = "Schedule"
Schema = "Schema"
Seeder = "Seeder"
Session = "Session"
Storage = "Storage"
Testing = "Testing"
Validation = "Validation"
View = "View"
Artisan = "Artisan"
Auth = "Auth"
Cache = "Cache"
Config = "Config"
Crypt = "Crypt"
DB = "DB"
Event = "Event"
Gate = "Gate"
Grpc = "Grpc"
Hash = "Hash"
Http = "Http"
Lang = "Lang"
Log = "Log"
Mail = "Mail"
Process = "Process"
Orm = "Orm"
Queue = "Queue"
RateLimiter = "RateLimiter"
Route = "Route"
Schedule = "Schedule"
Schema = "Schema"
Seeder = "Seeder"
Session = "Session"
Storage = "Storage"
Testing = "Testing"
Validation = "Validation"
View = "View"
Notification = "Notification"
)

var FacadeToBinding = map[string]string{
Artisan: binding.Artisan,
Auth: binding.Auth,
Cache: binding.Cache,
Config: binding.Config,
Crypt: binding.Crypt,
DB: binding.DB,
Event: binding.Event,
Gate: binding.Gate,
Grpc: binding.Grpc,
Hash: binding.Hash,
Http: binding.Http,
Lang: binding.Lang,
Log: binding.Log,
Mail: binding.Mail,
Orm: binding.Orm,
Process: binding.Process,
Queue: binding.Queue,
RateLimiter: binding.RateLimiter,
Route: binding.Route,
Schedule: binding.Schedule,
Schema: binding.Schema,
Seeder: binding.Seeder,
Session: binding.Session,
Storage: binding.Storage,
Testing: binding.Testing,
Validation: binding.Validation,
View: binding.View,
Artisan: binding.Artisan,
Auth: binding.Auth,
Cache: binding.Cache,
Config: binding.Config,
Crypt: binding.Crypt,
DB: binding.DB,
Event: binding.Event,
Gate: binding.Gate,
Grpc: binding.Grpc,
Hash: binding.Hash,
Http: binding.Http,
Lang: binding.Lang,
Log: binding.Log,
Mail: binding.Mail,
Orm: binding.Orm,
Process: binding.Process,
Queue: binding.Queue,
RateLimiter: binding.RateLimiter,
Route: binding.Route,
Schedule: binding.Schedule,
Schema: binding.Schema,
Seeder: binding.Seeder,
Session: binding.Session,
Storage: binding.Storage,
Testing: binding.Testing,
Validation: binding.Validation,
View: binding.View,
Notification: binding.Notification,
}
3 changes: 3 additions & 0 deletions contracts/foundation/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package foundation

import (
"context"
"github.com/goravel/framework/contracts/notification"

"github.com/goravel/framework/contracts/auth"
"github.com/goravel/framework/contracts/auth/access"
Expand Down Expand Up @@ -166,6 +167,8 @@ type Application interface {
MakeValidation() validation.Validation
// MakeView resolves the view instance.
MakeView() view.View
// MakeNotification resolves the notification instance.
MakeNotification() notification.Notification
// MakeSeeder resolves the seeder instance.
MakeSeeder() seeder.Facade
// MakeWith resolves the given type with the given parameters from the container.
Expand Down
25 changes: 25 additions & 0 deletions contracts/notification/notification.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package notification

type Notification interface {
Send(notifiable Notifiable) error
}

type Notif interface {
// Via Return to the list of channel names
Via(notifiable Notifiable) []string
}

type Channel interface {
// Send sends the given notification to the given notifiable.
Send(notifiable Notifiable, notif interface{}) error
}

type Notifiable interface {
// NotificationParams returns the parameters for the given key.
NotificationParams() map[string]interface{}
}

type PayloadProvider interface {
// PayloadFor returns prepared payload data for specific channel.
PayloadFor(channel string, notifiable Notifiable) (map[string]interface{}, error)
}
5 changes: 5 additions & 0 deletions facades/facades.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package facades

import (
"context"
"github.com/goravel/framework/contracts/notification"

"github.com/goravel/framework/contracts/auth"
"github.com/goravel/framework/contracts/auth/access"
Expand Down Expand Up @@ -150,3 +151,7 @@ func Validation() validation.Validation {
func View() view.View {
return App().MakeView()
}

func Notification() notification.Notification {
return App().MakeNotification()
}
12 changes: 12 additions & 0 deletions foundation/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
contractshttpclient "github.com/goravel/framework/contracts/http/client"
contractslog "github.com/goravel/framework/contracts/log"
contractsmail "github.com/goravel/framework/contracts/mail"
contractsotification "github.com/goravel/framework/contracts/notification"
contractsprocess "github.com/goravel/framework/contracts/process"
contractsqueue "github.com/goravel/framework/contracts/queue"
contractsroute "github.com/goravel/framework/contracts/route"
Expand All @@ -35,6 +36,7 @@ import (
contractstranslation "github.com/goravel/framework/contracts/translation"
contractsvalidation "github.com/goravel/framework/contracts/validation"
contractsview "github.com/goravel/framework/contracts/view"

"github.com/goravel/framework/support/color"
)

Expand Down Expand Up @@ -386,6 +388,16 @@ func (r *Container) MakeView() contractsview.View {
return instance.(contractsview.View)
}

func (r *Container) MakeNotification() contractsotification.Notification {
instance, err := r.Make(facades.FacadeToBinding[facades.Notification])
if err != nil {
color.Errorln(err)
return nil
}

return instance.(contractsotification.Notification)
}

func (r *Container) MakeWith(key any, parameters map[string]any) (any, error) {
return r.make(key, parameters)
}
Expand Down
49 changes: 49 additions & 0 deletions mocks/foundation/Application.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading