This repository was archived by the owner on Dec 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christoph
committed
Feb 27, 2018
1 parent
079244c
commit e3ecbe3
Showing
4 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Voyager Bread Builder | ||
This is a new Package which allows you to build extensive BREAD Views and Lists. | ||
Its works in a different way then Voyager. | ||
## Terminology | ||
##### View | ||
A View is a set of Formfields. They are used for Reading, Editing and Adding BREAD-Content. | ||
A View can contain the Relationships from its model. | ||
##### List | ||
A List is used for Browsing BREAD-Content and displaying Relationships in a View. | ||
It can contain its own fields, relationship fields and pivot fields. | ||
In the List-Builder you can set 3 different options: | ||
- **Searchable** Sets if this field is searchable (Global search **and** single-column-search) | ||
- **Orderable** Sets if this field is orderable. Please read the note [here](/docs/Relationships.md) | ||
- **Visible** Sets if this field is visible. Useful if you want to search a field but don't want to display it. | ||
|
||
Both Views and Lists can have a free-name (and get assigned to different Roles) | ||
|
||
|
||
## Read more about | ||
- [Relationships](/docs/Relationships.md) | ||
- [Formfields](/docs/Formfields.md) | ||
|
||
## Todo: | ||
- [] Assign views to Roles *or* create a Permission for each view | ||
- [] Validate relationship | ||
- [] Implement various FormFields | ||
- [] Add `disabled` option to Formfields | ||
- [] Change the way we get the Columns. | ||
Currently we read the Database, because there is no way getting the attributes through the model if theres no entry. | ||
- [] bla |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
## Formfields | ||
The Formfields have been revamped to be more flexible and do more work. | ||
A single Formfield has 6 tasks: | ||
#### 1. Generating the `Input` | ||
The input is displayed on `Edit` and `Add` pages | ||
Passed Variables: | ||
1. `content` The content from the Database | ||
2. `options` the options defined in View-Builder | ||
3. `name` the name of the field | ||
4. `input` true | ||
|
||
#### 2. Generating the `Output` | ||
This will be displayed in `Lists` and `Relationships` | ||
Passed Variables: | ||
1. `data` The input from the Database | ||
2. `multiple` Display multiple results or not | ||
3. `attribute` The attribute to be displayed if `multiple = true` | ||
4. `output` true | ||
|
||
|
||
#### 3. Generating its `Options` | ||
Options are displayed in the View-Builder | ||
Passed Variables: | ||
1. `options` The options for this specific Formfield | ||
|
||
#### 4. Generating a `Mockup` | ||
The mockup is displayed as a placeholder inside the View-Builder. | ||
Normally you just want this to be your disabled `Input` view. | ||
Passed Variables: | ||
1. `options` The options for this specific Formfield | ||
2. `mockup` true | ||
|
||
#### 5. Generating the `Content` | ||
This will show the Content for Read-Pages. | ||
Passed Variables: | ||
1. `data` The input from the Database | ||
2. `render` Render the Content, or return it (bool) | ||
3. `multiple` Display multiple results or not | ||
4. `attribute` The attribute to be displayed if `multiple = true` | ||
|
||
#### 6. Parsing its Content | ||
When submitting a form, the method `parse` will be called with the raw `input` data and the `options`. | ||
The method then parses the content to be written to the Database. | ||
|
||
#### Notice | ||
By default, the viewfile is expected to be `bread::formfields.CODENAME.TASK`. | ||
You can easily set your custom viewfile by adding `protected $viewfile = 'your.file';`. | ||
|
||
When calling any of the first five methods, a variable called `input`, `output`, `options`, `mockup` or `content` with value `true` is passed. | ||
If you want to use just one view-file for your Formfield, you just need to define your view-file and check which variable is set to true. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
## Relationships | ||
Relationships now work in a different way. | ||
These are the necessary steps: | ||
1. Include the `HasRelationships` Trait in your model: `use Bread\Traits\HasRelationships;` | ||
2. Use the Trait `use HasRelationships;` | ||
3. Define your relationship methods like `protected $relationships = ['categories', 'tags'];` | ||
This step will maybe get unneccesary with PHP 7.1 and Reflection | ||
|
||
Thats it. You can now drop your Relationships in the View-Builder, use single Fields in Lists, and use Pivot-Fields for `BelongsToMany` relationships. | ||
|
||
|
||
### A note on ordering relationships | ||
While searching relationships is possible with no problems, ordering by a relationship is very expensive. | ||
Try to avoid it if you have a lot of data. |