BlogUpdated

Why SeviaFlow starts with your data

“Check with Nina before offering a renewal discount.” A sales rep wants that note on the customer’s account, right where a colleague will see it before the next call. The billing service needs access to the same account so it can keep the company name and email address up to date. The discount discussion belongs in the sales panel.

Now suppose the billing system accepts company names up to 80 characters. A rep can change a name in the panel, and the billing service can change it over REST. Both edits need the same validation. If the limit lives in a Livewire form and again in an API request class, someone has to remember the second copy the next time the limit changes.

I built SeviaFlow for this point in a Laravel project. A SeviaFlow Resource is a PHP class that connects an Eloquent model to the ways people and software use it. Open CustomerResource and you can trace a rule from the form where a rep edits a customer to the API method that accepts the same change.

A directory for the sales team

CustomerResource points to the application’s existing Customer model. In its table definition, TextColumn::make('name')->searchable() lets a rep find a company by name. The Livewire panel uses the resource’s form definition when the rep opens that customer for editing.

CustomerResource.php
public static function form(Form $form): Form
{
    return $form->fields([
        TextField::make('name')->required()->maxLength(80),
        EmailField::make('email')->required(),
        TextareaField::make('notes')->label('Sales notes'),
    ]);
}

A team can ship that directory with SeviaFlow Core and UI. Its Laravel migrations define the customer table, and its Eloquent model owns the relationships. When the billing integration comes along, the team can add the API adapter to the same application.

An API for billing

The billing service needs to read the customer ID and update two contact fields. Once you import SeviaFlow\Core\Resources\ApiResource, you can describe that contract in a method on CustomerResource.

CustomerResource.php
public static function api(ApiResource $api): ApiResource
{
    return $api
        ->enabled()
        ->readable(['id', 'name', 'email'])
        ->updatable(['name', 'email'])
        ->useFormFieldRules();
}

useFormFieldRules() applies the form’s validation to fields the API accepts. An 81-character name fails the same length check whether a rep types it or the billing service sends it. The field lists are a separate decision. Billing can read id, name and email, and can update just name and email. The API adapter also uses this contract to generate its OpenAPI description. Your Laravel guard authenticates the caller, and your customer policy decides which records they may update.

A lookup tool for an AI assistant

Suppose a rep asks an assistant, “What email address do we have for customer 42?” The SeviaFlow adapter for the Model Context Protocol (MCP) lets you give the assistant a lookup tool for exactly that job. With the adapter enabled, import SeviaFlow\Mcp\McpResource and add one more method to CustomerResource.

CustomerResource.php
public static function mcp(McpResource $mcp): McpResource
{
    return $mcp
        ->enabled()
        ->operations(['get'])
        ->readable(['email']);
}

get takes a record ID and runs the lookup as the authenticated application user. If your resource limits sales reps to their own accounts, that scope applies to the lookup too. The adapter checks permission to view the individual record before returning its ID, revision and email address.

The public MCP adapter is available on Packagist as dev-main. This version uses the feat/module-configuration branch of SeviaFlow Core. Adapter source and setup · Package versions

Try changing the rule

For a local experiment, follow the customer directory walkthrough, add the form and REST API methods above, and configure an authenticated API client with permission to update a test customer. Leave a sales note on that record in the panel. Build the customer directory · Set up API access

Change maxLength(80) to maxLength(12). Try saving Northstar Supply in the panel, then send the same name in a PATCH to /api/admin/resources/customers/{id} using your test customer’s ID. Both edits should fail validation for name. Try Northstar and both should succeed.

Now read the customer back through the API. You should see the shorter name and the email address. Open the same record in the panel and you’ll also find the note you left for your colleague.