On this page
Custom Datasource
Caching
Bolt will automatically list the data sources from your app in the form builder as a collection.
There is a cache for all collections, so remember to flush the key bolt.datasources
From Database
Create a custom data source for your forms and make it available as a collection. Datasources are helpful for creating custom collections from different models or an external API.
To create datasource, use the following command, passing the name of the datasource:
1php artisan make:zeus-datasource Car
Customization
Check out the contract LaraZeus\Bolt\DataSources\DataSourceContract and see all the available methods.
Disabling
You can turn off any field temporally by adding:
1public bool $disabled = true;
From Enum
Create a normal enum class and implement LaraZeus\Bolt\Contracts\DataSourceEnum interface, for example:
1use Illuminate\Contracts\Support\Htmlable; 2use LaraZeus\Bolt\DataSources\DataSourceData; 3use LaraZeus\Bolt\Contracts\DataSourceEnum; 4 5enum Status: string implements DataSourceEnum 6{ 7 case Approve = 'approve'; 8 case Pending = 'pending'; 9 10 public function getDataSourceLabel(): string|Htmlable|null11 {12 return match ($this) {13 self::Approve => 'approved',14 self::Pending => 'waiting'15 };16 }17 18 public static function toDataSourceData(): DataSourceData19 {20 return DataSourceData::make(21 title: __('status'),22 class: static::class23 )24 25 //disable a source, optional: when configuring the fields you can turn off ability to select this data source.26 ->disabled(false)27 28 //sorting, optional29 ->sort(1);30 }31}
Customization
Check out the contract LaraZeus\Bolt\DataSources\DataSourceData and see all the available methods.