Laravel 类型事件\日期\范围的额外字段

Laravel 类型事件\日期\范围的额外字段,laravel,backpack-for-laravel,Laravel,Backpack For Laravel,我只在背包里学习田野。问题-注册类型“事件日期范围”时,我看到两个额外字段“开始日期”和“结束日期”。屏幕截图中的详细信息-。 为什么它们会出现?我做错了什么?(拉威尔5.4) 谢谢你的回复 我的“EventCrudController”- 你能在堆栈溢出上给我看一下你的routes/web.php文件的副本吗?它与路由无关。因为是一个范围,所以您将获得开始日期和结束日期。这是对的你好,朋友们!很抱歉反应太晚@PHPGrandMaster admin.php-@Indra我真的不知道该修复什么。

我只在背包里学习田野。问题-注册类型“事件日期范围”时,我看到两个额外字段“开始日期”和“结束日期”。屏幕截图中的详细信息-。 为什么它们会出现?我做错了什么?(拉威尔5.4) 谢谢你的回复

我的“EventCrudController”-


你能在堆栈溢出上给我看一下你的routes/web.php文件的副本吗?它与路由无关。因为是一个范围,所以您将获得开始日期和结束日期。这是对的你好,朋友们!很抱歉反应太晚@PHPGrandMaster admin.php-@Indra我真的不知道该修复什么。请详细说明您的想法。@DmitryAverin让我在新安装的背包中检查一下您的代码,我会回来找您的
<?php

namespace App\Http\Controllers\Admin;

use Backpack\CRUD\app\Http\Controllers\CrudController;

// VALIDATION: change the requests to match your own file names if you need form validation
use App\Http\Requests\EventRequest as StoreRequest;
use App\Http\Requests\EventRequest as UpdateRequest;

class EventCrudController extends CrudController
{
    public function setup()
    {

        /*
        |--------------------------------------------------------------------------
        | BASIC CRUD INFORMATION
        |--------------------------------------------------------------------------
        */
        $this->crud->setModel('App\Models\Event');
        $this->crud->setRoute(config('backpack.base.route_prefix') . '/event');
        $this->crud->setEntityNameStrings('event', 'events');

        /*
        |--------------------------------------------------------------------------
        | BASIC CRUD INFORMATION
        |--------------------------------------------------------------------------
        */

        $this->crud->setFromDb();

        // ------ CRUD FIELDS
        // $this->crud->addField($options, 'update/create/both');
        // $this->crud->addField ([ // Text
        //     'name' => 'body',
        //     'label' => "Body",
        //     'type' => 'wysiwyg',
        //     // optional
        //     //'prefix' => '',
        //     //'suffix' => ''
        // ]);
        // $this->crud->addFields($array_of_arrays, 'update/create/both');
        $this->crud->addFields([
                [
                 'name' => 'body',
                 'label' => "Body",
                 'type' => 'wysiwyg', 
                ],
                [
                'name' => 'event_date_range', // a unique name for this field
                            'start_name' => 'start_date', // the db column that holds the start_date
                            'end_name' => 'end_date', // the db column that holds the end_date
                            'label' => 'Event Date Range',
                            'type' => 'date_range',
                            // OPTIONALS
                            'start_default' => '2017-01-01 01:01', // default value for start_date
                            'end_default' => '2017-12-31 02:00', // default value for end_date
                            'date_range_options' => [ // options sent to daterangepicker.js
                                'timePicker' => true,
                                'locale' => ['format' => 'DD/MM/YYYY HH:mm']
                            ]
                ]
            ]);
        // $this->crud->removeField('name', 'update/create/both');
        // $this->crud->removeFields($array_of_names, 'update/create/both');
        // $this->crud->removeFields(['start_date', 'end_date']);

        // ------ CRUD COLUMNS
        // $this->crud->addColumn(); // add a single column, at the end of the stack
        // $this->crud->addColumns(); // add multiple columns, at the end of the stack
        // $this->crud->removeColumn('column_name'); // remove a column from the stack
        // $this->crud->removeColumns(['column_name_1', 'column_name_2']); // remove an array of columns from the stack
        // $this->crud->setColumnDetails('column_name', ['attribute' => 'value']); // adjusts the properties of the passed in column (by name)
        // $this->crud->setColumnsDetails(['column_1', 'column_2'], ['attribute' => 'value']);
         $this->crud->setColumns(['','body']);

        // ------ CRUD BUTTONS
        // possible positions: 'beginning' and 'end'; defaults to 'beginning' for the 'line' stack, 'end' for the others;
        // $this->crud->addButton($stack, $name, $type, $content, $position); // add a button; possible types are: view, model_function
        // $this->crud->addButtonFromModelFunction($stack, $name, $model_function_name, $position); // add a button whose HTML is returned by a method in the CRUD model
        // $this->crud->addButtonFromView($stack, $name, $view, $position); // add a button whose HTML is in a view placed at resources\views\vendor\backpack\crud\buttons
        // $this->crud->removeButton($name);
        // $this->crud->removeButtonFromStack($name, $stack);
        // $this->crud->removeAllButtons();
        // $this->crud->removeAllButtonsFromStack('line');

        // ------ CRUD ACCESS
        // $this->crud->allowAccess(['list', 'create', 'update', 'reorder', 'delete']);
        // $this->crud->denyAccess(['list', 'create', 'update', 'reorder', 'delete']);

        // ------ CRUD REORDER
        // $this->crud->enableReorder('label_name', MAX_TREE_LEVEL);
        // NOTE: you also need to do allow access to the right users: $this->crud->allowAccess('reorder');

        // ------ CRUD DETAILS ROW
        // $this->crud->enableDetailsRow();
        // NOTE: you also need to do allow access to the right users: $this->crud->allowAccess('details_row');
        // NOTE: you also need to do overwrite the showDetailsRow($id) method in your EntityCrudController to show whatever you'd like in the details row OR overwrite the views/backpack/crud/details_row.blade.php

        // ------ REVISIONS
        // You also need to use \Venturecraft\Revisionable\RevisionableTrait;
        // Please check out: https://laravel-backpack.readme.io/docs/crud#revisions
        // $this->crud->allowAccess('revisions');

        // ------ AJAX TABLE VIEW
        // Please note the drawbacks of this though:
        // - 1-n and n-n columns are not searchable
        // - date and datetime columns won't be sortable anymore
        // $this->crud->enableAjaxTable();

        // ------ DATATABLE EXPORT BUTTONS
        // Show export to PDF, CSV, XLS and Print buttons on the table view.
        // Does not work well with AJAX datatables.
        // $this->crud->enableExportButtons();

        // ------ ADVANCED QUERIES
        // $this->crud->addClause('active');
        // $this->crud->addClause('type', 'car');
        // $this->crud->addClause('where', 'name', '==', 'car');
        // $this->crud->addClause('whereName', 'car');
        // $this->crud->addClause('whereHas', 'posts', function($query) {
        //     $query->activePosts();
        // });
        // $this->crud->addClause('withoutGlobalScopes');
        // $this->crud->addClause('withoutGlobalScope', VisibleScope::class);
        // $this->crud->with(); // eager load relationships
        // $this->crud->orderBy();
        // $this->crud->groupBy();
        // $this->crud->limit();
    }

    public function store(StoreRequest $request)
    {
        // your additional operations before save here
        $redirect_location = parent::storeCrud();
        // your additional operations after save here
        // use $this->data['entry'] or $this->crud->entry
        return $redirect_location;
    }

    public function update(UpdateRequest $request)
    {
        // your additional operations before save here
        $redirect_location = parent::updateCrud();
        // your additional operations after save here
        // use $this->data['entry'] or $this->crud->entry
        return $redirect_location;
    }
}