2022-07-05 12:36:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
|
|
|
|
|
use App\Http\Requests\AttachmentRequest;
|
|
|
|
|
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
|
|
|
|
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class AttachmentCrudController
|
|
|
|
|
* @package App\Http\Controllers\Admin
|
|
|
|
|
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
|
|
|
|
*/
|
|
|
|
|
class AttachmentCrudController extends CrudController
|
|
|
|
|
{
|
|
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
|
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
|
|
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
|
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
|
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Configure the CrudPanel object. Apply settings to all operations.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function setup()
|
|
|
|
|
{
|
|
|
|
|
CRUD::setModel(\App\Models\Attachment::class);
|
|
|
|
|
CRUD::setRoute(config('backpack.base.route_prefix') . '/attachment');
|
|
|
|
|
CRUD::setEntityNameStrings('attachment', 'attachments');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Define what happens when the List operation is loaded.
|
|
|
|
|
*
|
|
|
|
|
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function setupListOperation()
|
|
|
|
|
{
|
2022-07-06 08:08:56 +00:00
|
|
|
$this->crud->setFromDb();
|
2022-07-05 12:36:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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;
|
2022-07-06 08:08:56 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'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'
|
|
|
|
|
],
|
2022-07-05 12:36:10 +00:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Define what happens when the Update operation is loaded.
|
|
|
|
|
*
|
|
|
|
|
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function setupUpdateOperation()
|
|
|
|
|
{
|
|
|
|
|
$this->setupCreateOperation();
|
|
|
|
|
}
|
|
|
|
|
}
|