Skip to content

Docs ‐ Menu

Isaac Sai edited this page Dec 28, 2023 · 2 revisions

Introduction to Menu

USSD menus although simple, can spiral out of handle quickly. Laravel USSD provides a class to help you create an easy-to-maintain menu.

Creating Menu

<?php

use Sparors\Ussd\Menu;

Menu::build()
    ->text('Choose One')
    ->lineBreak(2)
    ->listing(['Mango', 'Pear'])
    ->when(false, fn (Menu) => $menu->line('Next'))
    ->prepend(fn (Menu) => $menu->line('Generated with Laravel USSD'))
    ->append(fn (Menu) => $menu->lineBreak()->format('Powered by %s', 'Sparors'));

// Generated with Laravel USSD
// Choose One
// 
// 1.Mango
// 2.Pear
// 
// Powered by Sparors
Clone this wiki locally