nunomaduro / laravel-desktop-notifier

💻 Send notifications to your desktop from your Laravel Artisan Commands. An JoliNotif wrapper for Laravel.
http://nunomaduro.com
MIT License
454 stars 40 forks source link

ErrorException Array Offset #27

Open eiko03 opened 3 years ago

eiko03 commented 3 years ago
"message": "Trying to access array offset on value of type null",
"exception": "ErrorException",
"file": "D:\\WAM\\login-auth\\login-auth\\vendor\\nunomaduro\\laravel-desktop-notifier\\src\\LaravelDesktopNotifierServiceProvider.php",
"line": 40,

I have followed the readme and paste the same code as the read me. Doesn't work
owenvoke commented 3 years ago

Just for reference, what class is your command extending? This sounds like the $laravel property is not being set. Could you also confirm your framework version?

eiko03 commented 3 years ago

"laravel/framework": "^8.12", command is extending a custom class made only for this notify package @owenvoke

owenvoke commented 3 years ago

Does it extend Illuminate\Console\Command in your custom class?

I'll see if I can replicate this later. 👍🏻

eiko03 commented 3 years ago

yes i am extending this class, still error

owenvoke commented 3 years ago

I was unable to replicate this issue with Laravel 8 and a default command that just contains:

class NotifyCommand extends Command
{
    protected $signature = 'notify';

    public function handle()
    {
        $this->notify('Hello Web Artisan', 'Love beautiful code? We do too!');
    }
}

@nunomaduro, any ideas on this? 🤔

pboese commented 1 year ago

I ran into the same issue. The reason was I used it the __construct() method of the command instead of handle(). Move the notify() call into your handle() method and it should work.