2022-07-05 12:36:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
|
|
|
|
|
use App\Http\Requests\ApplicationRequest;
|
|
|
|
|
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
|
|
|
|
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class ApplicationCrudController
|
|
|
|
|
* @package App\Http\Controllers\Admin
|
|
|
|
|
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
|
|
|
|
*/
|
|
|
|
|
class ApplicationCrudController 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\Application::class);
|
|
|
|
|
CRUD::setRoute(config('backpack.base.route_prefix') . '/application');
|
|
|
|
|
CRUD::setEntityNameStrings('application', 'applications');
|
2022-09-21 09:01:56 +00:00
|
|
|
|
|
|
|
|
$this->crud->addFilter([
|
|
|
|
|
'name' => 'state',
|
|
|
|
|
'type' => 'dropdown',
|
|
|
|
|
'label' => 'State'
|
|
|
|
|
], [
|
|
|
|
|
'new' => 'new',
|
|
|
|
|
'applied' => 'applied',
|
|
|
|
|
'approved' => 'approved',
|
|
|
|
|
'archived' => 'archived'
|
|
|
|
|
], function ($value) { // if the filter is active
|
|
|
|
|
$this->crud->addClause('where', 'state', $value);
|
|
|
|
|
});
|
2022-07-05 12:36:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Define what happens when the List operation is loaded.
|
|
|
|
|
*
|
|
|
|
|
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function setupListOperation()
|
|
|
|
|
{
|
|
|
|
|
$this->crud->setFromDb();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Define what happens when the Create operation is loaded.
|
|
|
|
|
*
|
|
|
|
|
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function setupCreateOperation()
|
|
|
|
|
{
|
|
|
|
|
CRUD::setValidation(ApplicationRequest::class);
|
|
|
|
|
$this->crud->addFields([
|
2022-09-13 22:21:05 +00:00
|
|
|
[
|
|
|
|
|
'name' => 'account_id',
|
|
|
|
|
'type' => 'select',
|
|
|
|
|
'label' => 'Account',
|
|
|
|
|
'entity' => 'account',
|
|
|
|
|
'model' => "App\Models\Account",
|
|
|
|
|
'attribute' => 'legalization_number'
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'name' => 'status',
|
|
|
|
|
'label' => 'Status',
|
|
|
|
|
'type' => 'checkbox'
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'name' => 'state',
|
|
|
|
|
'label' => 'State',
|
|
|
|
|
'type' => 'select_from_array',
|
|
|
|
|
'options' => [
|
|
|
|
|
'new' => 'new',
|
|
|
|
|
'applied' => 'applied',
|
|
|
|
|
'approved' => 'approved',
|
|
|
|
|
'archive' => 'archive'
|
|
|
|
|
]
|
|
|
|
|
]
|
2022-07-05 12:36:10 +00:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Define what happens when the Update operation is loaded.
|
|
|
|
|
*
|
|
|
|
|
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function setupUpdateOperation()
|
|
|
|
|
{
|
|
|
|
|
$this->setupCreateOperation();
|
|
|
|
|
$this->crud->setFromDb();
|
|
|
|
|
}
|
|
|
|
|
}
|