birzha-legalizasia/app/Http/Controllers/Admin/TicketCrudController.php

121 lines
3.4 KiB
PHP
Executable File

<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\TicketRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
/**
* Class TicketCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class TicketCrudController 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;
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
* @return void
*/
public function setup()
{
CRUD::setModel(\App\Models\Ticket::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/ticket');
CRUD::setEntityNameStrings('ticket', 'tickets');
}
/**
* 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->addColumns([
[
'name' => 'title',
'type' => 'text',
'label' => 'Title'
],
[
'name' => 'content',
'type' => 'textarea',
'label' => 'Content'
],
[
'name' => 'client_id',
'entity' => 'client',
'type' => 'select',
'label' => 'Client',
'attribute' => 'email',
'model' => 'App\Models\Client'
],
[
'name' => 'status',
'type' => 'status',
'label' => 'Status'
]
]);
$this->crud->addButtonFromModelFunction('line', 'messages', 'messagesOfTicket', 'beginning');
}
/**
* Define what happens when the Create operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
protected function setupCreateOperation()
{
CRUD::setValidation(TicketRequest::class);
$this->crud->addFields([
[
'name' => 'title',
'type' => 'text',
'label' => 'Title'
],
[
'name' => 'content',
'type' => 'textarea',
'label' => 'Content'
],
[
'name' => 'client_id',
'entity' => 'client',
'type' => 'select',
'label' => 'Client',
'attribute' => 'email',
'model' => 'App\Models\Client'
],
[
'name' => 'status_id',
'entity' => 'status',
'type' => 'select',
'label' => 'Status',
'attribute' => 'name',
'model' => 'App\Models\Status'
],
]);
}
/**
* Define what happens when the Update operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
}
}