93 lines
3.1 KiB
PHP
93 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Requests\MultimediaCategoryRequest;
|
|
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
|
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
|
|
|
/**
|
|
* Class MultimediaCategoryCrudController
|
|
* @package App\Http\Controllers\Admin
|
|
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
|
*/
|
|
class MultimediaCategoryCrudController 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;
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\ReorderOperation;
|
|
|
|
/**
|
|
* Configure the CrudPanel object. Apply settings to all operations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function setup()
|
|
{
|
|
CRUD::setModel(\App\Models\MultimediaCategory::class);
|
|
CRUD::setRoute(config('backpack.base.route_prefix') . '/multimedia-category');
|
|
CRUD::setEntityNameStrings(trans('backpack::model.category'), trans('backpack::model.categories'));
|
|
}
|
|
|
|
/**
|
|
* 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('title');
|
|
CRUD::column('type')->type('select_from_array')->options(['image' => 'Image', 'video' => 'Video']);
|
|
|
|
/**
|
|
* 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(MultimediaCategoryRequest::class);
|
|
|
|
CRUD::field('title');
|
|
CRUD::field('type')->type('select_from_array')->options(['image' => 'Image', 'video' => 'Video']);
|
|
|
|
/**
|
|
* 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();
|
|
}
|
|
|
|
protected function setupReorderOperation()
|
|
{
|
|
// define which model attribute will be shown on draggable elements
|
|
$this->crud->set('reorder.label', 'title');
|
|
// define how deep the admin is allowed to nest the items
|
|
// for infinite levels, set it to 0
|
|
$this->crud->set('reorder.max_level', 1);
|
|
}
|
|
}
|