132 lines
4.0 KiB
PHP
Executable File
132 lines
4.0 KiB
PHP
Executable File
<?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('entrepreneur', 'entrepreneurs');
|
|
}
|
|
|
|
/**
|
|
* 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' => 'name',
|
|
'type' => 'text',
|
|
'label' => 'Name'
|
|
]);
|
|
CRUD::addColumn([
|
|
'name' => 'surname',
|
|
'type' => 'text',
|
|
'label' => 'Surname'
|
|
]);
|
|
CRUD::addColumn([
|
|
'name' => 'patronomic_name',
|
|
'type' => 'text',
|
|
'label' => 'Patronomic'
|
|
]);
|
|
|
|
|
|
/**
|
|
* 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' => 'name',
|
|
'label' => 'Name',
|
|
'type' => 'text',
|
|
],
|
|
[
|
|
'name' => 'surname',
|
|
'label' => 'Surname',
|
|
'type' => 'text',
|
|
],
|
|
[
|
|
'name' => 'patronomic_name',
|
|
'label' => 'Patronomic name',
|
|
'type' => 'text',
|
|
],
|
|
[
|
|
'name' => 'date_of_birth',
|
|
'label' => 'Date of birth',
|
|
'type' => 'date',
|
|
],
|
|
[
|
|
'name' => 'birth_place',
|
|
'label' => 'Birth place',
|
|
'type' => 'text',
|
|
],
|
|
[
|
|
'name' => 'registration_address',
|
|
'label' => 'Registration address',
|
|
'type' => 'text',
|
|
],
|
|
[
|
|
'label' => "citizenship_id",
|
|
'type' => 'select',
|
|
'name' => 'citizenship', // the method that defines the relationship in your Model
|
|
'entity' => 'citizenship', // the method that defines the relationship in your Model
|
|
'attribute' => 'name', // foreign key attribute that is shown to user
|
|
'model' => "App\Models\Country", // foreign key model
|
|
]
|
|
]);
|
|
|
|
}
|
|
|
|
/**
|
|
* Define what happens when the Update operation is loaded.
|
|
*
|
|
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
|
* @return void
|
|
*/
|
|
protected function setupUpdateOperation()
|
|
{
|
|
$this->setupCreateOperation();
|
|
}
|
|
}
|