crud->setFromDb(); } /** * Define what happens when the Create operation is loaded. * * @see https://backpackforlaravel.com/docs/crud-operation-create * @return void */ protected function setupCreateOperation() { CRUD::setValidation(AttachmentRequest::class); CRUD::addFields([ [ 'name' => 'name', 'type' => 'text' ], [ 'name' => 'size', 'type' => 'text' ], [ 'name' => 'type', 'label' => "Type", 'type' => 'select2_from_array', 'options' => ['docx' => 'docx', 'xls' => 'xls', 'pdf' => 'pdf'], 'allows_null' => true, ], [ // Upload 'name' => 'file', 'label' => 'File', 'type' => 'upload', 'upload' => true, 'disk' => 'uploads', // if you store files in the /public folder, please ommit this; if you store them in /storage or S3, please specify it; ], [ 'name' => 'document_id', 'type' => 'select', 'label' => 'Document', 'entity' => 'document', 'model' => "App\Models\Document", 'attribute' => 'name_ru' ], [ 'name' => 'application_id', 'type' => 'select', 'label' => 'Application', 'entity' => 'application', 'model' => "App\Models\Application", 'attribute' => 'account_id' ], ]); } /** * Define what happens when the Update operation is loaded. * * @see https://backpackforlaravel.com/docs/crud-operation-update * @return void */ protected function setupUpdateOperation() { $this->setupCreateOperation(); } }