Getting Started
Installation
bash
composer require 2wee/laravelRun the install command:
bash
php artisan 2wee:installThis publishes the config file and creates the app/TwoWee/Resources/ directory.
Configuration
Edit config/twowee.php:
php
return [
'prefix' => 'terminal', // URL prefix for all routes
'app_name' => 'My App', // Shown in menu top-left corner
'auth' => [
'username_field' => 'email', // 'email' or 'username'
],
'locale' => [
'date_format' => 'DD-MM-YYYY',
'decimal_separator' => ',',
'thousand_separator' => '.',
],
'work_date' => null, // null = today
'ui_strings' => [], // Override client UI text
];Run the migration
bash
php artisan migrateThis creates the twowee_tokens table for bearer token authentication.
Create Your First Resource
bash
php artisan 2wee:resource CustomerResource --model=CustomerThis scaffolds a resource file in app/TwoWee/Resources/CustomerResource.php. Edit it to define your form fields and table columns.
Other generators
bash
php artisan 2wee:lookup CountryLookup --model=Country # Reusable lookup class
php artisan 2wee:action PostSalesInvoice # Screen action / save action classExample resource
php
namespace App\TwoWee\Resources;
use TwoWee\Laravel\Columns\TextColumn;
use TwoWee\Laravel\Fields\Email;
use TwoWee\Laravel\Fields\Phone;
use TwoWee\Laravel\Fields\Text;
use TwoWee\Laravel\Resource;
use TwoWee\Laravel\Section;
class CustomerResource extends Resource
{
// That's your list screen, your card, your routes — all of it.
protected static string $model = \App\Models\Customer::class;
protected static string $label = 'Customer';
public static function form(): array
{
return [
Section::make('General')
->column(0)->rowGroup(0)
->fields([
Text::make('no')->label('No.')->width(20)->required()
->uppercase(),
Text::make('name')->label('Name')->width(30)->required(),
]),
Section::make('Contact')
->column(1)->rowGroup(0)
->fields([
Email::make('email')->label('E-Mail')->width(30),
Phone::make('phone')->label('Phone No.')->width(20),
]),
];
}
public static function table(): array
{
return [
TextColumn::make('no')->label('No.')->width(10),
TextColumn::make('name')->label('Name')->width('fill'),
TextColumn::make('city')->label('City')->width(20),
];
}
}Connect the TUI Client
Point the TUI client at http://your-app.test/terminal/menu/main. It will redirect to the login screen if authentication is required.
Routes
The plugin registers these routes automatically (prefix: /terminal):
| Method | URL | Purpose |
|---|---|---|
| GET | /terminal/auth/login | Login form |
| POST | /terminal/auth/login | Submit login |
| GET | /terminal/menu/main | Main menu |
| GET | /terminal/screen/{resource}/list | List screen |
| GET | /terminal/screen/{resource}/card/new | New record form |
| GET | /terminal/screen/{resource}/card/{id} | Existing record |
| POST | /terminal/screen/{resource}/card/new | Create record |
| POST | /terminal/screen/{resource}/card/{id}/save | Save changes |
| POST | /terminal/screen/{resource}/card/{id}/delete | Delete record |
| GET | /terminal/lookup/{field_id} | Lookup list |
| GET | /terminal/validate/{field_id}/{value} | Blur validation |
| GET | /terminal/drilldown/{field_id}/{key} | Drill-down data |
| POST | /terminal/action/{resource}/{id}/{action_id} | Screen action |