Crud: SublimeText plugin/snippets

Created on 9 Jun 2016  路  2Comments  路  Source: Laravel-Backpack/CRUD

One thing we could do to speed up development is NOT going to the documentation website every time we need the syntax for a certain field type.

A SublimeText plugin/collection of snippets will solve that problem for me. Here's the syntax I have in mind:

crud.addField.select_multiple 

=>

$this->crud->addField([       // SelectMultiple = n-n relationship (with pivot table)
    'label' => "Tags",
    'type' => 'select_multiple',
    'name' => 'tags', // the method that defines the relationship in your Model
    'entity' => 'tags', // the method that defines the relationship in your Model
    'attribute' => 'name', // foreign key attribute that is shown to user
    'model' => "App\Models\Tag", // foreign key model
    'pivot' => true, // on create&update, do you need to add/delete pivot table entries?
]);

I'm thinking an alternative shorter syntax will also be available:

crud.af.select_multiple

What I want from the syntax is for it to still read the same as the code you want to write, so it will be easy to remember:

  • $this->crud->addField() - reads crud add field
  • crud.addField.select_multiple - reads crud add field select multiple
  • crud.af.select_multiple - reads crud add field select multiple

Using the crud prefix would allow us to also do things like:

// addColumn
crud.ac.column_type => [column definition]
// removeColumn
crud.rc => $this->crud->removeColumn('column_name');
// removeField
crud.rf => $this->crud->removeField('name', 'update/create/both);
// allowAccess
crud.aa => $this->crud->allowAccess(['list', 'create', 'update', 'reorder', 'delete']);
// denyAccess
crud.da => $this->crud->denyAccess(['list', 'create', 'update', 'reorder', 'delete']);
// enableDetailsRow
crud.edr =>
  $this->crud->enableDetailsRow();
  $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
// addClause
crud.addClause => $this->crud->addClause('where', 'name', '==', 'car');

Any thoughts / improvements?

help wanted

Most helpful comment

Two years is long enough for me to assume that the help wanted is not going to appear - this should be put on the backlog - please re-open if needed.

All 2 comments

Other SublimeText possible commands:
1) When on a model, run "Use CrudTrait";
2) When in routes file, run "Add CRUD route product"

Two years is long enough for me to assume that the help wanted is not going to appear - this should be put on the backlog - please re-open if needed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

deepaksp picture deepaksp  路  3Comments

packytagliaferro picture packytagliaferro  路  3Comments

sseggio picture sseggio  路  3Comments

abewartech picture abewartech  路  3Comments

AlexanderWM picture AlexanderWM  路  3Comments