110 lines
4.0 KiB
PHP
Executable File
110 lines
4.0 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Requests\CompanyRequest;
|
|
use App\Models\Account;
|
|
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
|
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
|
|
|
/**
|
|
* Class CompanyCrudController
|
|
* @package App\Http\Controllers\Admin
|
|
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
|
*/
|
|
class CompanyCrudController extends CrudController
|
|
{
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
|
// use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation { store as traitStore; }
|
|
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\Company::class);
|
|
CRUD::setRoute(config('backpack.base.route_prefix') . '/company');
|
|
CRUD::setEntityNameStrings(trans('app.company.title'), trans('app.company.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' => 'name', 'type' => 'text', 'label' => trans('app.company.name')],
|
|
['name' => 'short_name', 'type' => 'text', 'label' => trans('app.company.short_name')],
|
|
['name' => 'registration_number', 'type' => 'text', 'label' => trans('app.company.registration_number')],
|
|
['name' => 'state_registration_agency', 'type' => 'text', 'label' => trans('app.company.state_registration_agency')],
|
|
['name' => 'registration_place', 'type' => 'text', 'label' => trans('app.company.registration_place')],
|
|
['name' => 'registration_address', 'type' => 'text', 'label' => trans('app.company.registration_address')],
|
|
[ // Date
|
|
'name' => 'registration_date',
|
|
'label' => trans('app.company.registration_date'),
|
|
'type' => 'date'
|
|
]
|
|
]);
|
|
|
|
}
|
|
|
|
protected function setupShowOperation()
|
|
{
|
|
|
|
$this->setupListOperation();
|
|
|
|
}
|
|
|
|
/**
|
|
* Define what happens when the Create operation is loaded.
|
|
*
|
|
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
|
* @return void
|
|
*/
|
|
protected function setupCreateOperation()
|
|
{
|
|
CRUD::setValidation(CompanyRequest::class);
|
|
CRUD::addFields([
|
|
['name' => 'name', 'type' => 'text', 'label' => trans('app.company.name')],
|
|
['name' => 'short_name', 'type' => 'text', 'label' => trans('app.company.short_name')],
|
|
['name' => 'registration_number', 'type' => 'text', 'label' => trans('app.company.registration_number')],
|
|
['name' => 'state_registration_agency', 'type' => 'text', 'label' => trans('app.company.state_registration_agency')],
|
|
['name' => 'registration_place', 'type' => 'text', 'label' => trans('app.company.registration_place')],
|
|
['name' => 'registration_address', 'type' => 'text', 'label' => trans('app.company.registration_address')],
|
|
]);
|
|
|
|
CRUD::addField([ // Date
|
|
'name' => 'registration_date',
|
|
'label' => trans('app.company.registration_date'),
|
|
'type' => 'date'
|
|
]);
|
|
|
|
/**
|
|
* 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();
|
|
}
|
|
|
|
}
|