محسن مهری
5 سال پیش توسط محسن مهری مطرح شد
0 پاسخ

مشکل در شخصی سازی notification laravel

سلام و عرض خسته نباشید مهندسین عزیز
آقا من یک نوتیفیکیشن دارم مینویسم سه تا کانال تعریف کردم و دارم توی این نوتیفیکیشن استفاده میکنم ازشون اما الان باید تابع via ام رو اینطوری بنویسم :

public function via($notifiable)
    {
        return [SmsChannel::class,MailChannel::class,TelChannel::class];
    }
# but i , m need write like this :
public function via($notifiable)
    {
        return ['sms','tel','mail'];
    }

توی کد توضیح دادم
یک تابع توی یکی از trait هایی که توی user.php اضافه شده به وسیله trait Notifiable که به این شکله :

public function routeNotificationFor($driver, $notification = null)
    {
        if (method_exists($this, $method = 'routeNotificationFor'.Str::studly($driver))) {
            return $this->{$method}($notification);
        }

        switch ($driver) {
            case 'database':
                return $this->notifications();
            case 'mail':
                return $this->email;
        }
    }

و این رو به این روش ویرایش کردم اما جواب نگرفتم ؟؟ چه کنم دوستان ؟

//refactor this function
    public function routeNotificationFor($driver, $notification = null)
    {
        if (method_exists($this, $method = 'routeNotificationFor'.Str::studly($driver))) {
            return $this->{$method}($notification);
        }

        switch ($driver) {
            case 'database':
                return $this->notifications();
            case 'mail':
                return MailChannel::class;
            case 'sms':
                return (SmsChannel::class);
            case 'telegram':
                return TelChannel::class;
        }
    }