PHP code example of deegitalbe / laravel-trustup-io-slack-notifications

1. Go to this page and download the library: Download deegitalbe/laravel-trustup-io-slack-notifications 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/ */

    

deegitalbe / laravel-trustup-io-slack-notifications example snippets


use Illuminate\Database\Eloquent\Model;
use Deegitalbe\LaravelTrustupIoSlackNotifications\Traits\Slack\SlackNotifiable;
use Deegitalbe\LaravelTrustupIoSlackNotifications\Contracts\Slack\SlackNotifiableContract;

use Illuminate\Notifications\Notification;

class User extends Model implements SlackNotifiableContract
{
    use SlackNotifiable;
}

use Illuminate\Notifications\Messages\SlackMessage;
use Deegitalbe\LaravelTrustupIoSlackNotifications\SlackNotification;
use Deegitalbe\LaravelTrustupIoSlackNotifications\Enum\SlackChannel;

class OrderReceived extends SlackNotification
{
    public function slackChannel($notifiable): string|SlackChannel
    {
        return SlackChannel::PRODUCTS;
    }

    public function slackMessage(SlackMessage $message, $notifiable): SlackMessage
    {
        return $message->content("A new order has been made.");
    }
}

use Illuminate\Notifications\Messages\SlackMessage;
use Deegitalbe\LaravelTrustupIoSlackNotifications\Enum\SlackChannel;
use Deegitalbe\LaravelTrustupIoSlackNotifications\Traits\Slack\IsSlackNotification;
use Deegitalbe\LaravelTrustupIoSlackNotifications\Contracts\Slack\SlackNotificationContract;

class OrderReceived extends Notification implements SlackNotificationContract
{
    use IsSlackNotification;

    public function slackChannel($notifiable): string|SlackChannel
    {
        return $notifiable->getSlackId();
    }

    public function slackMessage(SlackMessage $message, $notifiable): SlackMessage
    {
        return $message->content("A new order has been made.");
    }
}