first commit
This commit is contained in:
93
app/Http/Controllers/Admin/NewsCatalogCrudController.php
Normal file
93
app/Http/Controllers/Admin/NewsCatalogCrudController.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\NewsCatalogRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
/**
|
||||
* Class NewsCatalogCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class NewsCatalogCrudController 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\NewsCatalog::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/news-catalog');
|
||||
CRUD::setEntityNameStrings('news catalog', 'news catalogs');
|
||||
}
|
||||
|
||||
protected function setupReorderOperation()
|
||||
{
|
||||
CRUD::set('reorder.label', 'name');
|
||||
CRUD::set('reorder.max_level', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the List operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
||||
* @return void
|
||||
*/
|
||||
protected function setupListOperation()
|
||||
{
|
||||
if (! $this->crud->getRequest()->has('order')){
|
||||
$this->crud->orderBy('lft', 'asc')->orderBy('id', 'desc');
|
||||
}
|
||||
|
||||
CRUD::addColumn('#');
|
||||
CRUD::column('is_front_show')->label(trans('backend.columnName.is_front_show'))->type('checkbox');
|
||||
CRUD::column('name')->label(trans('backend.columnName.name'))->type('textarea_nl2br')->escaped(false)->searchLogic('text');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Create operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
||||
* @return void
|
||||
*/
|
||||
protected function setupCreateOperation()
|
||||
{
|
||||
CRUD::setValidation(NewsCatalogRequest::class);
|
||||
CRUD::addFields([
|
||||
[
|
||||
'name' => 'is_front_show',
|
||||
'label' => trans('backend.columnName.is_front_show'),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'name',
|
||||
'lable' => 'Name',
|
||||
'type' => 'text',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Update operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
||||
* @return void
|
||||
*/
|
||||
protected function setupUpdateOperation()
|
||||
{
|
||||
$this->setupCreateOperation();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user