You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
papamarfo edited this page Jul 30, 2026
·
3 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
<?phpuseSpeso\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', 'Speso'));
// Generated with Laravel USSD// Choose One// // 1.Mango// 2.Pear// // Powered by Speso
Localizing Menus
Menu also provides trans, transLine and transChoice, which build menu content from your app's translation files (lang/{locale}/...) instead of hardcoded strings, so the same flow can serve multiple languages.
A session's language choice can be persisted with Record::setLocale() so it's applied automatically on every following request — see Docs ‐ Record for details.