Skip to content

Commit

Permalink
simplified crud controller stub
Browse files Browse the repository at this point in the history
  • Loading branch information
tabacitu committed Aug 19, 2018
1 parent 2750736 commit 6b29994
Showing 1 changed file with 3 additions and 63 deletions.
66 changes: 3 additions & 63 deletions src/Console/stubs/crud-controller.stub
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DummyClassCrudController extends CrudController
{
/*
|--------------------------------------------------------------------------
| BASIC CRUD INFORMATION
| CrudPanel Basic Information
|--------------------------------------------------------------------------
*/
$this->crud->setModel('App\Models\DummyClass');
Expand All @@ -28,76 +28,16 @@ class DummyClassCrudController extends CrudController

/*
|--------------------------------------------------------------------------
| BASIC CRUD INFORMATION
| CrudPanel Configuration
|--------------------------------------------------------------------------
*/

// TODO: remove setFromDb() and manually define Fields and Columns
$this->crud->setFromDb();

// ------ CRUD COLUMNS
// $this->crud->addColumn(); // add a single column, at the end of the stack
// $this->crud->addColumns(); // add multiple columns, at the end of the stack
// $this->crud->removeColumn('column_name'); // remove a column from the stack
// $this->crud->removeColumns(['column_name_1', 'column_name_2']); // remove an array of columns from the stack
// $this->crud->setColumnDetails('column_name', ['attribute' => 'value']); // adjusts the properties of the passed in column (by name)
// $this->crud->setColumnsDetails(['column_1', 'column_2'], ['attribute' => 'value']);

// ------ CRUD FIELDS
// $this->crud->addField($options, 'update/create/both');
// $this->crud->addFields($array_of_arrays, 'update/create/both');
// $this->crud->removeField('name', 'update/create/both');
// $this->crud->removeFields($array_of_names, 'update/create/both');

// add asterisk for fields that are required in DummyClassRequest
$this->crud->setRequiredFields(StoreRequest::class, 'create');
$this->crud->setRequiredFields(UpdateRequest::class, 'edit');

// ------ CRUD BUTTONS
// possible positions: 'beginning' and 'end'; defaults to 'beginning' for the 'line' stack, 'end' for the others;
// $this->crud->addButton($stack, $name, $type, $content, $position); // add a button; possible types are: view, model_function
// $this->crud->addButtonFromModelFunction($stack, $name, $model_function_name, $position); // add a button whose HTML is returned by a method in the CRUD model
// $this->crud->addButtonFromView($stack, $name, $view, $position); // add a button whose HTML is in a view placed at resources\views\vendor\backpack\crud\buttons
// $this->crud->removeButton($name);
// $this->crud->removeButtonFromStack($name, $stack);
// $this->crud->removeAllButtons();
// $this->crud->removeAllButtonsFromStack('line');

// ------ CRUD ACCESS
// $this->crud->allowAccess(['list', 'create', 'update', 'reorder', 'delete']);
// $this->crud->denyAccess(['list', 'create', 'update', 'reorder', 'delete']);

// ------ CRUD REORDER
// $this->crud->enableReorder('label_name', MAX_TREE_LEVEL);
// NOTE: you also need to do allow access to the right users: $this->crud->allowAccess('reorder');

// ------ CRUD DETAILS ROW
// $this->crud->enableDetailsRow();
// NOTE: you also need to do allow access to the right users: $this->crud->allowAccess('details_row');
// NOTE: you also need to do overwrite the showDetailsRow($id) method in your EntityCrudController to show whatever you'd like in the details row OR overwrite the views/backpack/crud/details_row.blade.php

// ------ REVISIONS
// You also need to use \Venturecraft\Revisionable\RevisionableTrait;
// Please check out: https://laravel-backpack.readme.io/docs/crud#revisions
// $this->crud->allowAccess('revisions');

// ------ DATATABLE EXPORT BUTTONS
// Show export to PDF, CSV, XLS and Print buttons on the table view.
// $this->crud->enableExportButtons();

// ------ ADVANCED QUERIES
// $this->crud->addClause('active');
// $this->crud->addClause('type', 'car');
// $this->crud->addClause('where', 'name', '=', 'car');
// $this->crud->addClause('whereName', 'car');
// $this->crud->addClause('whereHas', 'posts', function($query) {
// $query->activePosts();
// });
// $this->crud->addClause('withoutGlobalScopes');
// $this->crud->addClause('withoutGlobalScope', VisibleScope::class);
// $this->crud->with(); // eager load relationships
// $this->crud->orderBy();
// $this->crud->groupBy();
// $this->crud->limit();
}

public function store(StoreRequest $request)
Expand Down

0 comments on commit 6b29994

Please sign in to comment.