first commit
This commit is contained in:
161
app/Http/Controllers/Admin/NewsCrudController.php
Normal file
161
app/Http/Controllers/Admin/NewsCrudController.php
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\NewsRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
/**
|
||||
* Class NewsCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class NewsCrudController 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\ActivityLog\Http\Controllers\Operations\ModelActivityOperation;
|
||||
//use \Backpack\ActivityLog\Http\Controllers\Operations\EntryActivityOperation;
|
||||
|
||||
/**
|
||||
* Configure the CrudPanel object. Apply settings to all operations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
CRUD::setModel(\App\Models\News::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/news');
|
||||
CRUD::setEntityNameStrings('最新消息', '最新消息');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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' => 'post_at',
|
||||
'label' => trans('backend.columnName.post_at'),
|
||||
'type' => 'datetime',
|
||||
//'format' => 'YYYY/MM/DD HH:mm:SS',
|
||||
],
|
||||
[
|
||||
'name' => 'is_front_show',
|
||||
'label' => trans('backend.columnName.is_front_show'),
|
||||
'type' => 'checkbox'
|
||||
],
|
||||
[
|
||||
'name' => 'title',
|
||||
'label' => trans('backend.columnName.title'),
|
||||
'type' => '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(NewsRequest::class);
|
||||
$this->crud->addFields([
|
||||
[
|
||||
'name' => 'news_catalog_id',
|
||||
'label' => trans('backend.columnName.catalog'),
|
||||
'type' => 'select2_nested',
|
||||
'entity' => 'newsCatalog',
|
||||
'attribute' => 'name',
|
||||
'model' => 'App\Models\NewsCatalog',
|
||||
],
|
||||
[
|
||||
'name' => 'post_at',
|
||||
'label' => trans('backend.columnName.post_at'),
|
||||
'type' => 'datetime_picker',
|
||||
'format' => 'YYYY/MM/DD HH:mm:SS',
|
||||
'default' => \Carbon\Carbon::now(),
|
||||
],
|
||||
[
|
||||
'name' => 'is_front_show',
|
||||
'label' => trans('backend.columnName.is_front_show'),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
|
||||
],
|
||||
[
|
||||
'name' => 'title',
|
||||
'label' => trans('backend.columnName.title'),
|
||||
'type' => 'text',
|
||||
|
||||
],
|
||||
[
|
||||
'name' => 'photos',
|
||||
'label' => trans('backend.columnName.cover'),
|
||||
'type' => 'upload_img_multiple',
|
||||
'upload' => true,
|
||||
'disk' => 'public',
|
||||
'hint' => '',
|
||||
'qty' => 1, // 0=no limit, >0=limit
|
||||
'showSingleChoise' => '0', // 0=hidden, 1=show(default)
|
||||
'showComment' => '0', // 0=hidden, 1=show(default)
|
||||
],
|
||||
//[
|
||||
// 'name' => 'description',
|
||||
// 'label' => trans('backend.columnName.description'),
|
||||
// 'type' => 'textarea'
|
||||
//],
|
||||
[
|
||||
'name' => 'body',
|
||||
'lable' => trans('backend.columnName.body'),
|
||||
'type' => 'tinymce',
|
||||
// optional overwrite of the configuration array
|
||||
'options' => [
|
||||
//'selector' => 'textarea.tinymce',
|
||||
//'skin' => 'dick-light',
|
||||
'plugins' => 'code lists advlist image link media anchor table hr imagetools importcss insertdatetime paste searchreplace textcolor textpattern help',
|
||||
'menubar' => 'edit insert view format help',
|
||||
'toolbar' => 'code undo redo bold italic alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image media link',
|
||||
'language' => str_replace('-', '_', app()->getLocale()),
|
||||
'height' => '500px',
|
||||
],
|
||||
],
|
||||
// [
|
||||
// 'name' => 'source_links',
|
||||
// 'lable' => 'Source Links',
|
||||
// 'type' => 'key_val_multiple',
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'seo_keyword',
|
||||
// 'label' => trans('backend.columnName.seo_keyword'),
|
||||
// 'type' => 'text'
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'seo_description',
|
||||
// 'label' => trans('backend.columnName.seo_description'),
|
||||
// 'type' => 'textarea'
|
||||
// ],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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