Download the PHP package idealogica/lavanda without Composer
On this page you can find all versions of the php package idealogica/lavanda. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download idealogica/lavanda
More information about idealogica/lavanda
Files in idealogica/lavanda
Package lavanda
Short Description Administrator control panel for Laravel application.
License MIT
Homepage https://github.com/idealogica/lavanda
Informations about the package lavanda
Lavanda - administrator control panel
Lavanda is an administrator control panel for Laravel application. It can be used for quick building or prototyping administrative interface of your site or service. The main idea of Lavanda is to enhance Eloquent models to provide all required information about your application entities and relationships in one place in unified way. So Lavanda model (which is based on Eloquent model) is used to incorporate your app bussiness logic and usually describes how to input, display, save and proccess your data.
Lavanda features:
- items lists viewing/searching/sorting and CRUD operations
- implementation of one-to-one, one-to-many, many-to-many relationships
- basic data types supported such as text, number, image, date
- basic controls supported such as input, date, image, fields set (one-to-one), rows set (one-to-many), lookup field (many-to-many)
- it allows to create forms with unlimited nesting level
- it's extendable: different kinds of data types and controls can be easily added
It uses laravel-form-builder for forms management.
Installation
Lavanda requires the following packages: Laravel 5, kris/laravel-form-builder, mistic100/randomcolor, idealogica/color and PHP >= 5.5.9.
Installation steps:
-
Add Lavanda to your composer.json file:
-
Add Lavanda service provider to config/app.php:
-
Publish Lavanda assets:
- If neccesary config, translation and views can also be published:
Quick start
Starting point of any Lavanda application is Idealogica\Lavanda\Model class. Any Lavanda model must be its child. It inherits form Laravel Illuminate\Database\Eloquent\Model class and can be used in a similar way so you can use it in both front-end and administrative parts of your application.
Any Lavanda model must override two methods listed below to provide basic information about describing object.
Model::buildListDescriptor
Used for items list descriptor adjustment. There you should add columns to display in table on items list page.
PresentationDescriptor::add method is used to describe how to display your data in columns:
Also you may add some constraints to Eloquent query builder using method PresentationDescriptor::addQueryBuilder:
Where $queryBuilder is a closure with a \Illuminate\Database\Eloquent\Builder $queryBuilder
as argument.
For now these types of presentaions can be used in PresentationDescriptor::add method:
- text - displays text
- image - displays image
- entity - represents sub-item in views
Model::buildItemDescriptor
Similar to the Model::buildListDescriptor. Used for item info descriptor adjustment. There you should add rows to display in table on item info page.
At this point if you have implelemented mehods described above you will meet all requirements
for you Lavanda model. So for now it can be used for displaying list of items and item itself.
Now you can follow http://yourdomain/admin adddress and test it.
Perhaps you may want to continue model tweaking and override other methods to provide
ability of searching, sorting, adding and editing items.
Model::buildActionsDescriptor
If overridden can be used for allowing some of controller actions. By default index (items list) and show (item info) actions of Lavanda EntityConstroller are allowed. If you want to extend your model functionality, you can grant permissions to acces other actions such as create, edit and destroy.
Model::buildStorageDescriptor
If overridden can be used for describing your external (non-database) storages. For example if you want to use image data type you should describe how to store it on your hard disk.
StorageDescriptor::add method is used to describe how to store your external files:
For now these types of storages can be used in StorageDescriptor::add method:
- image - stores/loads images from disk
Model::buildSearchDescriptor
If overridden can be used for describing fields to search by.
Model::buildSortDescriptor
If overridden can be used for describing fields to sort by.
SortDescriptor::add method is used to describe which fields to show in 'sort by' select:
Model::buildDeleteDescriptor
If overridden can be used to enumerate relations that will be used to delete related records.
Model::buildFormQuery
If overridden can be used for form data adjustment. There you may add some constraints to Eloquent query builder to get proper value to fill form on item edit page.
Model::buildForm
It's a main method of Lavanda model. If you plan to implement create and edit functions you should override this method. If overridden it can be used for adjustment of user input form.
Lavanda creates \Kris\LaravelFormBuilder\Form object and pases it as argument to Model::buildForm
method. Laravel-form-builder package offers various types of input controls that can be used in Lavanda.
Detailed information how to use laravel-form-builder you can find on
its manual page.
In addition to laravel-form-builder default controls Lavanda offers its own types:
- date - date input control
- image - image input control
- fieldset - sub-form from related model, one-to-one relationship
- rowset - multiple rows sub-forms for one-to-many relationship
- lookup - list of checkboxes for many-to-many relationship
Additionally you may want to override these methods of Lavanda model to change some of your model attributes.
Model::getName
Returns model name to display in UI.
Model::getPluralName
Returns model plural name to display in UI. For English language it's not neccessary to overrirde this method.
Model::hasController
Determines if model has a custom controller. Simply return true if you have your own custom controller to use with this model.
Model::getItemsPerPage
Returns number of list items per page.
Examples
There are some examples of Lavanda models shipped inside test environment:
- Blog post model
- Post tag model
- Post comment model
License
Lavanda is licensed under a MIT License.
All versions of lavanda with dependencies
laravel/framework Version ~5.1
kris/laravel-form-builder Version ~1.6
mistic100/randomcolor Version ~1.0
idealogica/color Version ~1.0.1