Bread stands for Browse, Read, Edit, Add and Delete. It allows the developer to rapidly create CRUD applications, simply by describing which fields to use.
A list of open-source packages we maintain. Click on a package to go the the docs to view full installation and usage information.
The Form Renderer allows you to render a form. Simply provide it the fields to render, and it will do the rest.
namespace App\Domains\Users\Controllers;
use Bread\Routes\UserRoutes;
use Bread\Fields\UserFields;
use Bread\Components\UserFormComponents;
final class UserController
{
public function create()
{
return FormRenderer::render()
->title('Create New User')
->fields(UserFields::class)
->components(UserFormComponents::class) // Optionally render custom components
->routes(UserRoutes::class);
}
}
namespace App\Domains\Users\Bread;
use Libaro\Bread\Fields\Text;
use Libaro\Bread\Fields\Fields;
use Libaro\Bread\Fields\Number;
use Libaro\Bread\Fields\Boolean;
use Libaro\Bread\Contracts\Renderer;
use Libaro\Bread\Contracts\Invokables;
final class UserFields implements Invokables
{
protected function __invoke(Renderer $renderer) {
return Fields::add(
Text::make('Name', 'name')
->readOnly(),
Text::make('Email', 'email')
Number::make('Age', 'age'),
Boolean::make('Active', 'active'),
Select::make('Role', 'user.role')->options([
'admin' => 'Admin',
'user' => 'User',
]),
);
}
}
We have provided a number of fields that you can use. You can also create your own field by extending the Field
class.
All fields have a range of options that you can use to customize the field.
Text
Number
Boolean
Select
Image
You provide options using a fluent api, which means you can chain them in any order.
readOnly
addWrapperClass
You can divide you form in tabs and specify which fields to show for each tab.
use Libaro\Bread\Fields\Tab;
use Libaro\Bread\Fields\Tabs;
return Fields::add(
Tabs::add(
Tab::make('Kenmerken',
Text::make('name', 'Naam')
->addWrapperClass($class, true),
BarMultiSelect::make('bars', 'Bars', $bars)
->addWrapperClass($class, true)
),
),
);
You can create your own custom Field
Libaro\Bread\Contracts\Field
class.Bread/Resources/ui/Components/Form/Fields
.Run php artisan bread:field NameOfYourField
to create a new field.
Two files will be created:
Bread/Fields/Custom/NameOfYourField.php
Bread/Resources/ui/Components/Form/Fields/NameOfYourField.vue
This field will automagically be recognized by Bread.