2022-06-28 11:28:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
|
|
|
|
|
use App\Http\Requests\BusinessRequest;
|
|
|
|
|
use App\Models\Account;
|
|
|
|
|
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
|
|
|
|
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class BusinessCrudController
|
|
|
|
|
* @package App\Http\Controllers\Admin
|
|
|
|
|
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
|
|
|
|
*/
|
|
|
|
|
class BusinessCrudController 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\Business::class);
|
|
|
|
|
CRUD::setRoute(config('backpack.base.route_prefix') . '/business');
|
|
|
|
|
CRUD::setEntityNameStrings('business', 'businesses');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Define what happens when the List operation is loaded.
|
|
|
|
|
*
|
|
|
|
|
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function setupListOperation()
|
|
|
|
|
{
|
|
|
|
|
CRUD::addColumn([
|
|
|
|
|
'name' => 'personal',
|
|
|
|
|
'type' => 'json',
|
|
|
|
|
'label' => 'Personal'
|
|
|
|
|
]);
|
|
|
|
|
CRUD::addColumn([
|
|
|
|
|
'name' => 'document',
|
|
|
|
|
'type' => 'json',
|
|
|
|
|
'label' => 'Document'
|
|
|
|
|
]);
|
|
|
|
|
CRUD::addColumn([
|
|
|
|
|
'name' => 'job',
|
|
|
|
|
'type' => 'json',
|
|
|
|
|
'label' => 'Job'
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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(BusinessRequest::class);
|
|
|
|
|
|
|
|
|
|
$this->crud->addFields([
|
|
|
|
|
[
|
|
|
|
|
'name' => 'personal',
|
|
|
|
|
'label' => 'Personal',
|
|
|
|
|
'type' => 'table',
|
|
|
|
|
'entity_singular' => 'option', // used on the "Add X" button
|
|
|
|
|
'columns' => [
|
|
|
|
|
'name' => 'Name',
|
|
|
|
|
'surname' => 'Surname',
|
|
|
|
|
'patronomic_name' => 'Patronomic name',
|
|
|
|
|
'date_of_birth' => 'Date of birth',
|
|
|
|
|
'birth_place' => 'Birth place',
|
|
|
|
|
'citizenship_id' => 'Citizenship ID',
|
|
|
|
|
'registration_address' => 'Registration address'
|
|
|
|
|
],
|
2022-07-05 12:36:10 +00:00
|
|
|
'max' => 15,
|
|
|
|
|
'min' => 0,
|
2022-06-28 11:28:57 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'name' => 'document',
|
|
|
|
|
'label' => 'Document',
|
|
|
|
|
'type' => 'table',
|
2022-07-05 12:36:10 +00:00
|
|
|
'entity_singular' => 'option',
|
2022-06-28 11:28:57 +00:00
|
|
|
'columns' => [
|
|
|
|
|
'doc_name' => 'Doc name',
|
|
|
|
|
'doc_series' => 'Doc series',
|
|
|
|
|
'doc_number' => 'Doc number',
|
|
|
|
|
'doc_date' => 'Doc date',
|
|
|
|
|
'doc_given_by' => 'Doc given by'
|
|
|
|
|
],
|
2022-07-05 12:36:10 +00:00
|
|
|
'max' => 15,
|
|
|
|
|
'min' => 0,
|
2022-06-28 11:28:57 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'name' => 'job',
|
|
|
|
|
'label' => 'Job',
|
|
|
|
|
'type' => 'table',
|
|
|
|
|
'entity_singular' => 'option', // used on the "Add X" button
|
|
|
|
|
'columns' => [
|
|
|
|
|
'work_place' => 'Work place',
|
|
|
|
|
'position' => 'Position',
|
|
|
|
|
'business_type' => 'Business type',
|
|
|
|
|
'licenses' => 'Licenses',
|
|
|
|
|
],
|
|
|
|
|
'max' => 15, // maximum rows allowed in the table
|
|
|
|
|
'min' => 0, // minimum rows allowed in the table
|
2022-07-15 05:44:52 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'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
|
2022-06-28 11:28:57 +00:00
|
|
|
]
|
|
|
|
|
]);
|
2022-07-15 05:44:52 +00:00
|
|
|
|
2022-06-28 11:28:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Define what happens when the Update operation is loaded.
|
|
|
|
|
*
|
|
|
|
|
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function setupUpdateOperation()
|
|
|
|
|
{
|
2022-07-15 06:00:40 +00:00
|
|
|
$this->setupCreateOperation();
|
2022-06-28 11:28:57 +00:00
|
|
|
}
|
|
|
|
|
}
|