PHP code example of abdulmatinsanni / api-x

1. Go to this page and download the library: Download abdulmatinsanni/api-x 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/ */

    

abdulmatinsanni / api-x example snippets


...

class User extends Model
{
    use Notifiable;

    public function routeNotificationForSmartSMS($notification)
    {
        return $this->phone_column;
    }
}



...

use AbdulmatinSanni\APIx\APIxMessage;
use AbdulmatinSanni\APIx\Channels\SmartSMSChannel;

class DemoNotification extends Notification
{
    use Queueable;
    
    ...
    
    public function via($notifiable)
    {
        return [SmartSMSChannel::class];
    }

    ...
    
    public function toSmartSMS($notifiable)
    {
        return (new APIxMessage())
                    ->from($this->from)
                    ->message($this->message);
    }
}



...

public class NotificationsController extends Controller
{
    public function notify()
    {
        $user = User::firstOrFail();
        $user->notify(new DemoNotification("SarahFound", "Hi, you are invited to our seminar!!!!!"));
    }
}

\---src
    |   APIx.php
    |   APIxMessage.php
    |   APIxServiceProvider.php
    |
    +---Channels
    |       SmartSMSChannel.php
    |
    +---Commands
    |   \---Log
    |           ClearCommand.php
    |           DisplayCommand.php
    |
    +---config
    |       api-x.php
    |
    +---Controllers
    |       LogController.php
    |
    +---Exceptions
    |       CouldNotSendNotification.php
    |       InvalidConfiguration.php
    |
    +---Facades
    |       APIxFacade.php
    |
    \---resources
        \---views
                log.blade.php
 php
// config/app.php

'providers' => [
    ...
    AbdulmatinSanni\APIx\APIxServiceProvider::class,
],

'aliases' => [
    'APIx' => AbdulmatinSanni\APIx\Facades\APIxFacade::class,
],
 php
...

use APIx;

class SMSController extends Controller
{
    public function send(Request $request)
    {
        $response = APIx::to($request->recipient)
            ->from($request->name)
            ->message($request->message)
            ->send();
        
        return $response;
    }
}