PHP code example of palpalani / bayrewards-laravel

1. Go to this page and download the library: Download palpalani/bayrewards-laravel 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/ */

    

palpalani / bayrewards-laravel example snippets


use Palpalani\BayRewards\Facades\BayRewards;

$bayRewards = BayRewards::client();

use Palpalani\BayRewards\BayRewards;

class YourController
{
    public function index()
    {
        $bayRewards = BayRewards::client();
        // Use $bayRewards...
    }
}

use Palpalani\BayRewards\Facades\BayRewards;

$bayRewards = BayRewards::client();
$store = $bayRewards->storeDetails()->get('<Store-Access-Token>');

use Palpalani\BayRewards\Facades\BayRewards;

$bayRewards = BayRewards::client();
$features = $bayRewards->getStoreFeatures()->get('<Store-Access-Token>');

use Palpalani\BayRewards\Facades\BayRewards;

$bayRewards = BayRewards::client();
$activity = $bayRewards->createActivity()->post('<Store-Access-Token>', [
    'title' => 'Purchase Reward', // Required
    'icon' => 'https://example.com/icon.png', // Required
]);

use Palpalani\BayRewards\Facades\BayRewards;

$bayRewards = BayRewards::client();
$activity = $bayRewards->getActivity()->get('<Store-Access-Token>', '<Activity-ID>');

use Palpalani\BayRewards\Facades\BayRewards;

$bayRewards = BayRewards::client();
$activity = $bayRewards->updateActivity()->post('<Store-Access-Token>', [
    'title' => 'Updated Purchase Reward', // Required
    'icon' => 'https://example.com/updated-icon.png', // Required
    'activity_id' => 12345, // Required
]);

use Palpalani\BayRewards\Facades\BayRewards;

$bayRewards = BayRewards::client();
$updatePoints = $bayRewards->updatePoints()->post('<Store-Access-Token>', [
    'activity_id' => 12345, // Required - from activity payload
    'customer_email' => '[email protected]', // Required
]);

use Palpalani\BayRewards\Facades\BayRewards;

$bayRewards = BayRewards::client();

// Get all customers with default pagination
$customers = $bayRewards->allCustomers()->get('<Store-Access-Token>');

// Get customers with custom pagination and filters
$customers = $bayRewards->allCustomers()->get(
    '<Store-Access-Token>', // Required
    1,                      // Optional - page number (default: 1)
    25,                     // Optional - limit per page (default: 25)
    'vip',                  // Optional - customer type filter (default: null)
    'john'                  // Optional - search query (default: '')
);
bash
php artisan vendor:publish --tag="bayrewards-laravel-config"