tanthammar/tall-blueprint-addon
Installation:
composer require tanthammar/tall-blueprint-addon
php artisan vendor:publish --provider="TanThammar\BlueprintAddon\BlueprintAddonServiceProvider"
config/blueprint-addon.php) and migrations if needed.First Use Case:
php artisan blueprint:build
app/Http/Livewire/Forms.resources/blueprints/ (e.g., UserBlueprint.yaml).UserForm.php).draft.yaml).Where to Look First:
resources/blueprints/ → Edit draft.yaml to customize fields.app/Http/Livewire/Forms/ → Review auto-generated form logic.config/blueprint-addon.php → Configure global defaults (e.g., field types, exclusions).Define Blueprint Fields:
Edit draft.yaml to specify fields for your model (e.g., UserBlueprint.yaml):
fields:
- name: name
type: text
rules: required|max:255
- name: email
type: email
rules: required|email
exclude_fields to omit columns (e.g., timestamps).Generate & Customize:
php artisan blueprint:build
UserForm.php (e.g., custom validation, actions).public function mount()
{
$this->fields[] = new CustomField();
}
Integration with Controllers:
public function render()
{
return view('livewire.user-form')->layout('layouts.app');
}
store/update logic from controllers if copied from draft.yaml.Splitting Create/Update Forms:
class UserCreateForm extends UserForm
{
public function rules()
{
return ['password' => 'required|confirmed'];
}
}
php artisan blueprint:build --model=User
BlueprintAddon::extend('custom_field', function () {
return new CustomField();
});
relationship fields in draft.yaml:
fields:
- name: posts
type: relationship
model: Post
key: user_id
Generated Code is a Draft:
UserForm.php and adjust:
text → textarea for long content).select field fails, ensure the options are properly defined in YAML:
- name: status
type: select
options: ["active", "inactive", "pending"]
Test File Conflicts:
public function test_form_submission()
{
$this->actingAs(user())
->livewire(UserForm::class)
->fillForm(['name' => 'Test'])
->assertSetOnSubmit();
}
php artisan blueprint:test to regenerate tests (if updated).Code Duplication:
store/update logic in draft.yaml is duplicated in both controllers and Livewire.submit() method.YAML Parsing Quirks:
true/false (not yes/no or 1/0).type: nested and proper relationship config.Livewire Component Naming:
ModelNameForm (e.g., UserForm). Avoid naming conflicts with existing components.Field Not Rendering? Check:
$fillable.rules() method includes the field.Validation Errors:
rules in YAML match Laravel’s validation syntax.rules() in the form class if needed:
public function rules()
{
return $this->validateOnly(['email' => 'required|unique:users']);
}
Relationship Fields:
model and key in YAML are correct.belongsTo/hasMany defined.Custom Field Types: Register new field types in a service provider:
BlueprintAddon::extend('custom_field', function ($field) {
return new class($field) extends Field {
public function render()
{
return view('livewire.fields.custom')->with($this);
}
};
});
Blueprint Hooks:
Override the blueprint builder in AppServiceProvider:
public function boot()
{
BlueprintAddon::macro('customLogic', function ($blueprint) {
$blueprint->fields[] = new CustomField();
});
}
Post-Generation Hooks: Use events to modify generated files:
BlueprintAddon::listen('afterGenerate', function ($model, $form) {
$form->appendFile(__DIR__.'/stubs/custom-method.stub');
});
Excluding Models:
Configure exclusions in config/blueprint-addon.php:
'excluded_models' => [
'PasswordReset',
'FailedJob',
],
draft.yaml to reduce form complexity.blueprint:build in production).How can I help you explore Laravel packages today?