bolt

you are reading the documentation for version v2 our latest version is v3 make sure to select the correct version.
to check your version use: composer show lara-zeus/bolt

Extensions

Bolt over a simple way to build your own application around the forms, with a simple interface, called extensions :

Extensions are hooks based classes that let you perform your logic around the forms or catch the submission and do more integrations with other apps or external APIs. for example before showing the form, or after storing the data etc...

Available Hooks:

  • canView before displaying the form, you can do some checks.

  • render what to show at the beginning of the form, you can return a view to show more info or instructors while filling out the form.

-formComponents return an array of filament components to add them to the form in the frontend

  • store the store logic for the extension, insert to any DB or external API.

  • postStore this is typically used for sending only. It will be executed after saving the form

  • submittedRender this will show any info after saving the form, like a request number or more buttons and links

Creating an Extension

create a class in your app with the following content:

I will create a command later :)

1 
2<?php
3 
4namespace App\Zeus\Extensions;
5 
6use Filament\Forms\Components\TextInput;
7use LaraZeus\Bolt\Contracts\Extension;
8use LaraZeus\Bolt\Models\Form;
9 
10class Items implements Extension
11{
12 public function label(): string
13 {
14 return 'Ext Name';
15 }
16 
17 public function canView(Form $form, array $data): bool|array|null
18 {
19 // abort_if ...
20 // get the ext app and return it back, so you can receive it in the render
21 // return [];
22 }
23 
24 public function render(Form $form, array $data): string|null
25 {
26 // set any data and pas it to your view
27 // $data['items'] = ...
28 
29 // return view();
30 }
31 
32 public function formComponents(Form $form): array|null
33 {
34 return [
35 TextInput::make('extensions.order_number'),
36 ];
37 }
38 
39 public function store(Form $form, array $data): array|null
40 {
41 /*$model = Model::create([
42 'order_number' => $data['order_number'],
43 // ...
44 ]);*/
45 
46 // return these data to recive them after the form submitted
47 // $data['model'] = $model;
48 
49 return $data;
50 }
51 
52 public function postStore(Form $form, array $data): void
53 {
54 // send emails
55 // fire some events
56 }
57 
58 public function SubmittedRender(Form $form, array $data): string|null
59 {
60 // return view()->with('data', $data);
61 }
62}

Enabling The Extension

in your zeus-bolt config file, add your extension to the array:

1'extensions' => [
2 \App\Zeus\Extensions\Items::class,
3],

now when creating or editing a form, you will see the tab Extensions, and you can select any extension per form.

Zeus is an open-source project. Thanks to my sponsors for helping me maintain this project.