PHP code example of asseco-voice / laravel-plan-router

1. Go to this page and download the library: Download asseco-voice/laravel-plan-router 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/ */

    

asseco-voice / laravel-plan-router example snippets


public function __invoke(ReceiveEmailRequest $request)
{
    // email() is some arbitrary method in form request 
    // returning a CanMatch instance from given request data.
    $canMatchInstance = $request->email(); 

    $matchedPlan = InboxService::match($canMatchInstance);

    return response('success');
}



$message = Message::create([
    'title'         => 'some title',
    'description'   => 'some description',
]);

// Let's say Plan 2 was hit
$matchedPlan = InboxService::match($canMatchInstance);

$message->applyPlanValues($matchedPlan);

dd(
    $message->title,      // Will dump "some title" as Plan 2 doesn't have title in plan_model_values.
    $message->description // Will dump "Modify this" because of Plan 2 hit. 
);