birzha-legalizasia/app/Http/Controllers/Admin/ContractCrudController.php

165 lines
5.3 KiB
PHP

<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\ContractRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
use Illuminate\Support\Facades\Lang;
/**
* Class ContractCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class ContractCrudController 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\Contract::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/contract');
CRUD::setEntityNameStrings(trans('app.contract.title'), trans('app.contract.list_title'));
}
/**
* Define what happens when the List operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
CRUD::addColumns([
[
'name' => 'InputNumber',
'label' => trans('app.contract.input_number'),
'type' => 'text'
],
[
'name' => 'InputDate',
'label' => trans('app.contract.input_date'),
'type' => 'text'
],
[
'name' => 'RegDate',
'label' => trans('app.contract.reg_date'),
'type' => 'text'
],
[
'name' => 'MarkerSpec',
'label' => trans('app.contract.status_marker'),
'type' => 'closure',
'function' => function($entry) {
return Lang::get('imported.markerspec.' . $entry->MarkerSpec);
}
],
[
'name' => 'Workflow_ID',
'label' => trans('app.contract.workflow'),
'type' => 'closure',
'function' => function($entry) {
return Lang::get('imported.workflow.' . $entry->Workflow_ID);
}
],
[
'name' => 'Note',
'label' => trans('app.contract.note'),
'type' => 'text'
],
[
'name' => 'Remark',
'label' => trans('app.contract.remark'),
'type' => 'text'
],
]);
/**
* 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(ContractRequest::class);
CRUD::addFields([
[
'name' => 'InputNumber',
'label' => trans('app.contract.input_number'),
'type' => 'text'
],
[
'name' => 'InputDate',
'label' => trans('app.contract.input_date'),
'type' => 'text'
],
[
'name' => 'RegDate',
'label' => trans('app.contract.reg_date'),
'type' => 'text'
],
[
'name' => 'MarkerSpec',
'label' => trans('app.contract.status_marker'),
'type' => 'closure',
'function' => function($entry) {
return Lang::get('imported.markerspec.' . $entry->MarkerSpec);
}
],
[
'name' => 'Workflow_ID',
'label' => trans('app.contract.workflow'),
'type' => 'closure',
'function' => function($entry) {
return Lang::get('imported.workflow.' . $entry->Workflow_ID);
}
],
[
'name' => 'Note',
'label' => trans('app.contract.note'),
'type' => 'text'
],
[
'name' => 'Remark',
'label' => trans('app.contract.remark'),
'type' => 'text'
],
]);
/**
* 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();
}
}