Skip to content

Instantly share code, notes, and snippets.

@chriscalip
Created January 9, 2018 23:16
Show Gist options
  • Select an option

  • Save chriscalip/9d7a3018115cbef00f45b0d0909fe57c to your computer and use it in GitHub Desktop.

Select an option

Save chriscalip/9d7a3018115cbef00f45b0d0909fe57c to your computer and use it in GitHub Desktop.
Explaining the idea of Is it possible for Backpack\CRUD\app\Http\Controllers\CrudController on method setup to change the underlying query? eg. /admin/vocabulary/{vid}/overview Overview CRUD of terms that are children of vocabulary {vid}?
<?php
namespace App\Http\Controllers\Admin;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use App\Http\Requests\VocabularyCrudRequest as StoreRequest;
use App\Http\Requests\VocabularyCrudRequest as UpdateRequest;
class VocabularyCrudController extends CrudController {
public function setup() {
$this->crud->setModel('App\Vocabulary');
$this->crud->setRoute('admin/vocabulary');
$this->crud->setEntityNameStrings('vocabulary', 'vocabularies');
$this->crud->setColumns(['name']);
$this->crud->addField([
'name' => 'name',
'label' => 'Vocabulary',
'type' => 'text',
'placeholder' => 'Your title here',
]);
$this->crud->addField([
'name' => 'description',
'label' => 'Description',
'type' => 'ckeditor',
'placeholder' => 'Your textarea text here',
]);
$this->crud->addButtonFromView('line', 'listofterms', 'listofterms', 'beginning');
}
public function store(StoreRequest $request)
{
return parent::storeCrud();
}
public function update(UpdateRequest $request)
{
return parent::updateCrud();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment