Laravel-Backpack / devtools-issues

Bug reports and feature requests for our closed-source DevTools package
4 stars 1 forks source link

This message appears after checking "Generate CRUD" and press save: array_filter(): Argument #1 ($array) must be of type array, null given #46

Closed 77ghjr77 closed 1 year ago

77ghjr77 commented 2 years ago

123456

456

log content: array_filter(): Argument #1 ($array) must be of type array, null given {"exception":"[object] (TypeError(code: 0): array_filter(): Argument #1 ($array) must be of type array, null given at /var/www/vendor/backpack/crud/src/app/Library/CrudPanel/Traits/SaveActions.php:52)

In fact, after reloading the web page, I found that the program was executed successfully. How can I solve it please? (I installed it normally and did not manually modify the program.)

77ghjr77 commented 2 years ago

@tabacitu Sorry, I forgot to say. I'm building the backup in a docker container, not sure if the issue is related to this.

Also I am attaching pictures that may be relevant to this issue. dsgsdgsd 54612313

pxpm commented 2 years ago

I think this is the same issue as https://github.com/Laravel-Backpack/CRUD/issues/2708

@77ghjr77 can you provide me the generated controller when you got the error ?

Cheers

77ghjr77 commented 2 years ago

@pxpm Thanks.

<?php

namespace App\Http\Controllers\Admin;

use App\Http\Requests\BuyRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;

/**
 * Class BuyCrudController
 * @package App\Http\Controllers\Admin
 * @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
 */
class BuyCrudController 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;

    /**
     * Configure the CrudPanel object. Apply settings to all operations.
     * 
     * @return void
     */
    public function setup()
    {
        CRUD::setModel(\App\Models\Buy::class);
        CRUD::setRoute(config('backpack.base.route_prefix') . '/buy');
        CRUD::setEntityNameStrings('buy', 'buys');
    }

    /**
     * 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('money');

        /**
         * 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(BuyRequest::class);

        CRUD::field('money');

        /**
         * 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();
    }
}
tabacitu commented 1 year ago

Unfortunately we couldn't replicate the issue... Please, if you get this error again, let us know how to better reproduce it... A video recording with the Chrome console would be great too - maybe that would provide more info.

If anybody else gets it, please let us know and we'll reopen... but until then... we have no idea what to do here, sorry 🤷‍♂️

We'll close this as there's nothing we can do right now. But... I have a feeling this isn't over. Let us Know.

Cheers!