Upstart for Laravel

Usage

  • Complete the Installation steps above.

  • Create a new block on the developer portal.

  • Create a new route in your application to handle the block.

  • Add the Upcoach\UpstartForLaravel\Http\Middleware\EnsureUpcoachRequestIsValid middleware to the route.

Route::group(
    ['middleware' => [EnsureUpcoachRequestIsValid::class]], 
    function () {
        Route::get('/your-block-connector-path', YourBlockController::class);
    }
);
  • Create a new controller for the route.

class YourBlockController extends Controller
{
    public function __invoke(Request $request)
    {
        /**
         * Parameters coming from the upcoach
         * app_id
         * organization_id
         * program_id
         * block_id
         * program_block_id
         * user_id
         * user_role
         */

        // You can access the installation via the request object.
        $installation = $request->installation;

        // You can use the installation to query the upcoach API if needed.
        $client = app(
           Upcoach\UpstartForLaravel\Api\Client::class, [$installation]
        );
        $programInfo = $client->getProgramInfo($request->program_id);

        // Your code here.
    }
}
Previous
Installation