PHP code example of laravel-notification-channels / hipchat

1. Go to this page and download the library: Download laravel-notification-channels/hipchat library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

laravel-notification-channels / hipchat example snippets


// config/app.php
'providers' => [
    ...
    NotificationChannels\HipChat\HipChatServiceProvider::class,
],

// config/services.php
...
'hipchat' => [
    'token' => env('HIPCHAT_TOKEN'),
    // Default room (optional)
    'room' => 'Notifications',
    // Base URL for Hipchat API server (optional)
    'url' => 'https://api.your.hipchat.server.com',
],
...

public function toHipChat($notifiable)
{
    return HipChatMessage::create()
        ->text('Laravel 5.3 has arrived!')
        ->notify(true)
        ->card(Card::create()
            ->title('Laravel')
            ->style(CardStyles::APPLICATION)
            ->url('http://laravel.com')
            ->html('Laravel 5.3 has arrived! The best release ever!')
            ->cardFormat(CardFormats::MEDIUM)
            ->icon('http://bit.ly/2c7ntiF')
            ->activity('Laravel 5.3 has arrived!', 'http://bit.ly/2c7ntiF')
            ->addAttribute(CardAttribute::create()
                ->label('Laravel Scout')
                ->icon('http://bit.ly/2c7ntiF')
                ->value('Driver based full-text search.')
                ->url('https://laravel.com/docs/5.3/scout')
            )
            ->addAttribute(CardAttribute::create()
                ->label('Laravel Echo')
                ->icon('http://bit.ly/2c7ntiF')
                ->value('Event broadcasting, evolved.')
                ->url('https://laravel.com/docs/5.3/broadcasting')
            )
            ->addAttribute(CardAttribute::create()
                ->label('Laravel Passport')
                ->icon('http://bit.ly/2c7ntiF')
                ->value('API authentication.')
                ->url('https://laravel.com/docs/5.3/passport')
            )
        );
}
 php
use NotificationChannels\HipChat\HipChatChannel;
use NotificationChannels\HipChat\HipChatMessage;
use Illuminate\Notifications\Notification;

class UserRegistered extends Notification
{
    public function via($notifiable)
    {
        return [HipChatChannel::class];
    }

    public function toHipChat($notifiable)
    {
        return HipChatMessage::create()
            ->room('New Registrations')
            ->html("<strong>A new user has registered!</strong>")
            ->success()
            ->notify();
    }
}
 php
public function toHipChat($notifiable)
{
    return HipChatFile::create($this->user->photo);
}
 php
public function toHipChat($notifiable)
{
    return HipChatFile::create($this->user->photo);
        ->text("Look we've got a new user!");
}
 php
public function toHipChat($notifiable)
{
    return HipChatFile::create()
        ->fileName('user_photo.png')
        ->fileType('image/png')
        ->fileContent(fopen('http://example.com/user/photo/johndoe', 'r'))
        ->text("Look we've got a new user!");
}