webfactor /
laravel-backpack-documents
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Webfactor\Laravel\Backpack\Documents\Controllers; |
||
| 4 | |||
| 5 | use Backpack\CRUD\app\Http\Controllers\CrudController; |
||
| 6 | use Webfactor\Laravel\Backpack\Documents\Requests\DocumentRequest as StoreRequest; |
||
| 7 | use Webfactor\Laravel\Backpack\Documents\Requests\DocumentUpdateRequest as UpdateRequest; |
||
| 8 | |||
| 9 | class DocumentCrudController extends CrudController |
||
| 10 | { |
||
| 11 | protected $types = [ |
||
| 12 | 'plaintext' => [ |
||
| 13 | 'field' => 'textarea', |
||
| 14 | 'attrLabel' => 'textareaAttributes' |
||
| 15 | ], |
||
| 16 | 'html' => [ |
||
| 17 | 'field' => 'summernote', |
||
| 18 | 'attrLabel' => 'options' |
||
| 19 | ], |
||
| 20 | 'md' => [ |
||
| 21 | 'field' => 'simplemde', |
||
| 22 | 'attrLabel' => 'simplemdeAttributesRaw' |
||
| 23 | ], |
||
| 24 | ]; |
||
| 25 | |||
| 26 | public function setup() |
||
| 27 | { |
||
| 28 | /* |
||
| 29 | |-------------------------------------------------------------------------- |
||
| 30 | | BASIC CRUD INFORMATION |
||
| 31 | |-------------------------------------------------------------------------- |
||
| 32 | */ |
||
| 33 | $this->crud->setModel(config('webfactor.documents.model_class')); |
||
| 34 | $this->crud->setRoute(config('webfactor.documents.backend.route_prefix') . '/' . config('webfactor.documents.backend.route')); |
||
| 35 | $this->crud->setEntityNameStrings(trans('webfactor::documents.entity_name_singular'), |
||
| 36 | trans('webfactor::documents.entity_name_plural')); |
||
| 37 | |||
| 38 | /* |
||
| 39 | |-------------------------------------------------------------------------- |
||
| 40 | | BASIC CRUD INFORMATION |
||
| 41 | |-------------------------------------------------------------------------- |
||
| 42 | */ |
||
| 43 | |||
| 44 | // ------ CRUD FIELDS |
||
| 45 | |||
| 46 | $this->crud->addField([ |
||
| 47 | 'name' => 'type', |
||
| 48 | 'label' => 'Dokumentenart', |
||
| 49 | 'type' => 'select_from_array', |
||
| 50 | 'options' => $this->getTypeOptions(), |
||
| 51 | 'allows_null' => false, |
||
| 52 | 'allows_multiple' => false, |
||
| 53 | ]); |
||
| 54 | |||
| 55 | $this->crud->addField([ |
||
| 56 | 'name' => 'title', |
||
| 57 | 'label' => trans('webfactor::documents.title'), |
||
| 58 | ]); |
||
| 59 | |||
| 60 | $this->crud->addField([ |
||
| 61 | 'name' => 'body', |
||
| 62 | 'label' => trans('webfactor::documents.body'), |
||
| 63 | 'type' => $this->bodyFieldType(), |
||
| 64 | $this->bodyFieldAttributesLabel() => $this->bodyFieldAttributes(), |
||
| 65 | ]); |
||
| 66 | |||
| 67 | // ------ CRUD COLUMNS |
||
| 68 | |||
| 69 | $this->crud->addColumns([ |
||
| 70 | [ |
||
| 71 | 'name' => 'translated_type', |
||
| 72 | 'label' => trans('webfactor::documents.type'), |
||
| 73 | ], |
||
| 74 | [ |
||
| 75 | 'name' => 'title', |
||
| 76 | 'label' => trans('webfactor::documents.title'), |
||
| 77 | ], |
||
| 78 | [ |
||
| 79 | 'name' => 'body', |
||
| 80 | 'label' => trans('webfactor::documents.body'), |
||
| 81 | ], |
||
| 82 | ]); |
||
| 83 | |||
| 84 | // ------ CRUD BUTTONS |
||
| 85 | |||
| 86 | // ------ CRUD ACCESS |
||
| 87 | |||
| 88 | collect(config('webfactor.documents.access', []))->each(function ($enabled, $key) { |
||
| 89 | if ($enabled) { |
||
| 90 | $this->crud->allowAccess($key); |
||
| 91 | } else { |
||
| 92 | $this->crud->denyAccess($key); |
||
| 93 | } |
||
| 94 | }); |
||
| 95 | |||
| 96 | // ------ CRUD REORDER |
||
| 97 | |||
| 98 | // ------ CRUD DETAILS ROW |
||
| 99 | |||
| 100 | // ------ REVISIONS |
||
| 101 | |||
| 102 | // ------ AJAX TABLE VIEW |
||
| 103 | |||
| 104 | // ------ DATATABLE EXPORT BUTTONS |
||
| 105 | |||
| 106 | // ------ ADVANCED QUERIES |
||
| 107 | } |
||
| 108 | |||
| 109 | public function getTypeOptions() |
||
| 110 | { |
||
| 111 | $types = collect(config('webfactor.documents.types')); |
||
| 112 | |||
| 113 | return $types->mapWithKeys(function ($type) { |
||
| 114 | return [$type => trans('webfactor::documents.types.' . $type)]; |
||
| 115 | }); |
||
| 116 | } |
||
| 117 | |||
| 118 | public function bodyFieldType() |
||
|
0 ignored issues
–
show
|
|||
| 119 | { |
||
| 120 | return $this->types[config('webfactor.documents.body_type', 'plaintext')]['field']; |
||
| 121 | } |
||
| 122 | |||
| 123 | public function bodyFieldAttributesLabel() |
||
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a Loading history...
|
|||
| 124 | { |
||
| 125 | return $this->types[config('webfactor.documents.body_type', 'plaintext')]['attrLabel']; |
||
| 126 | } |
||
| 127 | |||
| 128 | public function bodyFieldAttributes() |
||
| 129 | { |
||
| 130 | $type = config('webfactor.documents.body_type', 'plaintext'); |
||
| 131 | return config('webfactor.documents.field_editor_attributes.'.$type, []); |
||
| 132 | } |
||
| 133 | |||
| 134 | public function store(StoreRequest $request) |
||
| 135 | { |
||
| 136 | // your additional operations before save here |
||
| 137 | $redirect_location = parent::storeCrud($request); |
||
|
0 ignored issues
–
show
It seems like you call parent on a different method (
storeCrud() instead of store()). Are you sure this is correct? If so, you might want to change this to $this->storeCrud().
This check looks for a call to a parent method whose name is different than the method from which it is called. Consider the following code: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The Loading history...
|
|||
| 138 | // your additional operations after save here |
||
| 139 | // use $this->data['entry'] or $this->crud->entry |
||
| 140 | return $redirect_location; |
||
| 141 | } |
||
| 142 | |||
| 143 | public function update(UpdateRequest $request) |
||
| 144 | { |
||
| 145 | // your additional operations before save here |
||
| 146 | $redirect_location = parent::updateCrud($request); |
||
|
0 ignored issues
–
show
It seems like you call parent on a different method (
updateCrud() instead of update()). Are you sure this is correct? If so, you might want to change this to $this->updateCrud().
This check looks for a call to a parent method whose name is different than the method from which it is called. Consider the following code: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The Loading history...
|
|||
| 147 | // your additional operations after save here |
||
| 148 | // use $this->data['entry'] or $this->crud->entry |
||
| 149 | return $redirect_location; |
||
| 150 | } |
||
| 151 | } |
||
| 152 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.