Skip to content

Commit feea329

Browse files
committed
added docblocks and comments about the fluent syntax to the crud-controller stub
I don't really like how this makes the controller look - it makes it quite messy. But I imagine the added comments will be VERY useful to first-time Backpack users, and to users who have upgraded to 4.1 without knowing about the new fluent syntax. The links to the operations make it additionally messy, but those too should be very useful - just one click and go the operation docs. While very useful, I really don't like the end result though, so in a future version I plan to make the comments & docblocks configurable. Personally I'll probably be removing them from all my controllers, as soon as it's generated. I'm open to suggestions and opinions about these comments - how we can both make it easy to understand AND make it cleaner.
1 parent 71f20ad commit feea329

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/Console/stubs/crud-controller.stub

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,60 @@ class DummyClassCrudController extends CrudController
1919
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
2020
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
2121

22+
/**
23+
* Configure the CrudPanel object. Apply settings to all operations.
24+
*
25+
* @return void
26+
*/
2227
public function setup()
2328
{
2429
CRUD::setModel(\App\Models\DummyClass::class);
2530
CRUD::setRoute(config('backpack.base.route_prefix') . '/dummy_class');
2631
CRUD::setEntityNameStrings('dummy_class', 'DummyTable');
2732
}
2833

34+
/**
35+
* Define what happens when the List operation is loaded.
36+
*
37+
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
38+
* @return void
39+
*/
2940
protected function setupListOperation()
3041
{
3142
CRUD::setFromDb(); // columns
43+
44+
/**
45+
* Columns can be defined using the fluent syntax or array syntax:
46+
* - CRUD::column('price')->type('number');
47+
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
48+
*/
3249
}
3350

51+
/**
52+
* Define what happens when the Create operation is loaded.
53+
*
54+
* @see https://backpackforlaravel.com/docs/crud-operation-create
55+
* @return void
56+
*/
3457
protected function setupCreateOperation()
3558
{
3659
CRUD::setValidation(DummyClassRequest::class);
3760

3861
CRUD::setFromDb(); // fields
62+
63+
/**
64+
* Fields can be defined using the fluent syntax or array syntax:
65+
* - CRUD::field('price')->type('number');
66+
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
67+
*/
3968
}
4069

70+
/**
71+
* Define what happens when the Update operation is loaded.
72+
*
73+
* @see https://backpackforlaravel.com/docs/crud-operation-update
74+
* @return void
75+
*/
4176
protected function setupUpdateOperation()
4277
{
4378
$this->setupCreateOperation();

0 commit comments

Comments
 (0)