This repository has been archived by the owner on Mar 2, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SelectRelationField and FieldWithRelation
- Loading branch information
Showing
20 changed files
with
575 additions
and
58 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Changelog | ||
|
||
## 1.0.2 | ||
|
||
### Added | ||
|
||
- `SelectRelationField` | ||
- `FieldWithRelation` | ||
|
||
## 1.0.1 | ||
|
||
### Added | ||
|
||
- Default option on `FieldWithOptions` | ||
- `beforeSave` method on `Field` |
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 |
---|---|---|
@@ -1,3 +1,122 @@ | ||
# Routes and controllers | ||
|
||
Coming soon. | ||
Each `Crudable` model is managed by a `CrudManager` instance. | ||
|
||
## Usage | ||
|
||
By default, the `CrudManager` is automatically and basicly configured. | ||
This configuration comes from the `getCrudManager` on the `Crudable` trait, but you can override it. | ||
|
||
In your model: | ||
```php | ||
use Crudable; | ||
|
||
public function getCrudManager() | ||
{ | ||
$manager = CrudManager::make($this); | ||
|
||
// Configuration of your manager. | ||
|
||
return $manager; | ||
} | ||
``` | ||
|
||
## Configuration | ||
|
||
Many methods are available to configure the way your `Crudable` model is managed. | ||
|
||
### Controller | ||
|
||
```php | ||
$manager->setController('ModelController'); | ||
``` | ||
|
||
All actions will use the `ModelController` located in the namespace `App\Http\Controllers`. | ||
|
||
### Routes | ||
|
||
By default all you model crud routes are: | ||
|
||
- [Route URI] => [Route name] | ||
- model/index => model.index | ||
- model/create => model.create | ||
- model/store => model.store | ||
- model/edit/{id} => model.edit | ||
- model/update/{id} => model.update | ||
- model/delete/{id}/{csrf} => model.delete | ||
|
||
Where the 'model' value is the model name, ex: `Post` => 'posts, `Category` => 'categories', ... | ||
|
||
You can change all crud routes URI prefix like this: | ||
```php | ||
$manager->setUriPrefix('admin/posts'); | ||
``` | ||
|
||
You also can change the custom prefix for the named routes: | ||
```php | ||
$manager->setNamePrefix('admin.posts'); | ||
``` | ||
|
||
### Name | ||
|
||
By default the name of the crud is the name of the model, but you can configure it like this: | ||
```php | ||
$manager->setName('Post'); | ||
``` | ||
|
||
The name is used to display a title on the table and the form. | ||
|
||
### Entries per page | ||
|
||
You can customize entries displayed per page like this: | ||
```php | ||
$manager->setPerPage(50); | ||
``` | ||
|
||
By default, 25 entries are displayed per page. | ||
|
||
## Register routes | ||
|
||
All `Crudable` model comes with a static `registerRoutes` method. | ||
|
||
Once routes and controller are configured, you can bind you crud model routes in your routes file like this: | ||
```php | ||
// routes/web.php | ||
Model::registerRoutes(); | ||
``` | ||
|
||
## API | ||
|
||
The `CrudManager` instance comes with many public method. | ||
|
||
```php | ||
$manager = $model->getCrudManager(); | ||
|
||
// Returns the number of entries per page | ||
// => 25 | ||
$manager->getPerPage(); | ||
|
||
// Returns the name of the CRUD | ||
// => 'Model' | ||
$manager->getName(); | ||
|
||
// Returns the controller | ||
// => 'ModelController' | ||
$manager->getController(); | ||
|
||
// Returns URL for a route | ||
// => 'model/store' | ||
$manager->getActionRoute('store'); | ||
|
||
// Returns needed method for a route | ||
// => 'POST' | ||
$manager->getActionMethod('store'); | ||
|
||
// Returns the URI prefix | ||
// => 'model/' | ||
$manager->getUriPrefix(); | ||
|
||
// Returns the routes name prefix | ||
// => 'model.' | ||
$manager->getNamePrefix(); | ||
``` |
Oops, something went wrong.