120 lines
3.8 KiB
PHP
120 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Requests\BrokerAttachmentRequest;
|
|
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
|
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
|
|
|
/**
|
|
* Class BrokerAttachmentCrudController
|
|
* @package App\Http\Controllers\Admin
|
|
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
|
*/
|
|
class BrokerAttachmentCrudController 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\BrokerAttachment::class);
|
|
CRUD::setRoute(config('backpack.base.route_prefix') . '/broker-attachment');
|
|
CRUD::setEntityNameStrings('broker attachment', 'broker attachments');
|
|
}
|
|
|
|
/**
|
|
* Define what happens when the List operation is loaded.
|
|
*
|
|
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
|
* @return void
|
|
*/
|
|
protected function setupListOperation()
|
|
{
|
|
|
|
$this->crud->setFromDb();
|
|
/**
|
|
* Columns can be defined using the fluent syntax or array syntax:
|
|
* - CRUD::column('price')->type('number');
|
|
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
|
|
*/
|
|
}
|
|
|
|
/**
|
|
* Define what happens when the Create operation is loaded.
|
|
*
|
|
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
|
* @return void
|
|
*/
|
|
protected function setupCreateOperation()
|
|
{
|
|
CRUD::setValidation(BrokerAttachmentRequest::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'
|
|
],
|
|
]);
|
|
|
|
/**
|
|
* Fields can be defined using the fluent syntax or array syntax:
|
|
* - CRUD::field('price')->type('number');
|
|
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
|
|
*/
|
|
}
|
|
|
|
/**
|
|
* Define what happens when the Update operation is loaded.
|
|
*
|
|
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
|
* @return void
|
|
*/
|
|
protected function setupUpdateOperation()
|
|
{
|
|
$this->setupCreateOperation();
|
|
}
|
|
}
|