137 lines
4.6 KiB
PHP
Executable File
137 lines
4.6 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('company', 'companies');
|
|
}
|
|
|
|
/**
|
|
* Define what happens when the List operation is loaded.
|
|
*
|
|
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
|
* @return void
|
|
*/
|
|
protected function setupListOperation()
|
|
{
|
|
CRUD::column('name');
|
|
CRUD::column('short_name');
|
|
CRUD::column('registration_number');
|
|
CRUD::addColumn([ // Date
|
|
'name' => 'registration_date',
|
|
'label' => 'Regitration date',
|
|
'type' => 'date'
|
|
]);
|
|
CRUD::column('state_registration_agency');
|
|
CRUD::column('registration_place');
|
|
CRUD::column('registration_address');
|
|
CRUD::column('fond_capital');
|
|
CRUD::column('management_types');
|
|
CRUD::column('signers');
|
|
CRUD::column('share_holders');
|
|
CRUD::column('organizational_form');
|
|
CRUD::column('is_agent');
|
|
|
|
|
|
/**
|
|
* 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(CompanyRequest::class);
|
|
CRUD::field('name');
|
|
CRUD::field('short_name');
|
|
CRUD::field('registration_number');
|
|
CRUD::addField([ // Date
|
|
'name' => 'registration_date',
|
|
'label' => 'Regitration date',
|
|
'type' => 'date'
|
|
]);
|
|
CRUD::field('state_registration_agency');
|
|
CRUD::field('registration_place');
|
|
CRUD::field('registration_address');
|
|
CRUD::field('fond_capital');
|
|
CRUD::field('management_types');
|
|
CRUD::field([
|
|
'name' => 'signers',
|
|
'label' => 'Signers',
|
|
'type' => 'table',
|
|
'entity_singular' => 'option', // used on the "Add X" button
|
|
'columns' => [
|
|
'fullname' => 'Fullname',
|
|
'birthdate_n_birthplace' => 'Birthdate, place',
|
|
'citizenzhip' => 'Citizenship',
|
|
'registratino_address' => 'Registration address',
|
|
'' => '',
|
|
],
|
|
'max' => 15, // maximum rows allowed in the table
|
|
'min' => 0, // minimum rows allowed in the table
|
|
]);
|
|
CRUD::field('share_holders');
|
|
CRUD::field('organizational_form');
|
|
CRUD::field('is_agent');
|
|
CRUD::addField([
|
|
'label' => "profile",
|
|
'type' => 'select',
|
|
'name' => 'account.id', // the method that defines the relationship in your Model
|
|
'entity' => 'account', // the method that defines the relationship in your Model
|
|
'attribute' => 'id', // foreign key attribute that is shown to user
|
|
'model' => "App\Models\Account", // foreign key model
|
|
]);
|
|
|
|
/**
|
|
* 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();
|
|
}
|
|
|
|
}
|