Coder Social home page Coder Social logo

Comments (19)

pxpm avatar pxpm commented on August 18, 2024 1

Hello @yabbou

I just moved your issue from crud repository to generators, I think here is the correct place for it.

The error states that the controller already exists. Did you try deleting it and running the command again ?

Can you make sure you are using the last version of generators ? It's 3.1.3 atm.

Best,
Pedro

from generators.

promatik avatar promatik commented on August 18, 2024 1

Hi @yabbou, I tried to generate a model with blueprint and then build backpack, and the model got correctly fixed with the CrudTrait. Do you still happen to have this problem?

from generators.

promatik avatar promatik commented on August 18, 2024 1

@yabbou you'll need to run

  • composer update backpack/crud to update Backpack CRUD
  • composer update backpack/generators to update Backpack Generators

Please give it a try and let us know the result 🙌

from generators.

tabacitu avatar tabacitu commented on August 18, 2024 1

@promatik I also noticed this problem this week. I generated a few models and the Generators didn't fill in the column & fields - so I think there's truly a bug here - and big one.

Do you mind investigating this please and create a PR if possible? If it doesn't fill in the fields&columns, this package only provides a minor boost in productivity so it's pretty big problem.

from generators.

promatik avatar promatik commented on August 18, 2024 1

@tabacitu I've found the bug causing the problem reported by @yabbou #95 (comment), and I've just opened a PR for that #104.

I think this issue is no longer a problem, I'll close it for now.
Let's move the conversation to #104

from generators.

welcome avatar welcome commented on August 18, 2024

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication channels:

  • Bug Reports, Feature Requests - Github Issues (here);
  • Quick help (How do I do X) - Gitter Chatroom;
  • Long questions (I have done X and Y and it won't do Z wtf) - Stackoverflow, using the backpack-for-laravel tag;
  • Showing off something you've made, asking for opinion on Backpack/Laravel matters - Reddit;

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

--
Justin Case
The Backpack Robot

from generators.

welcome avatar welcome commented on August 18, 2024

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication mediums:

  • Bug Reports, Feature Requests - Github Issues (here);
  • Quick help (How do I do X) - Gitter Chatroom;
  • Long questions (I have done X and Y and it won't do Z wtf) - Stackoverflow, using the backpack-for-laravel tag;

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

--
Justin Case
The Backpack Robot

from generators.

yabbou avatar yabbou commented on August 18, 2024

composer.json: Using version ^3.1 for backpack/generators. Tried now to delete and re-run, but i was unsuccessful.

I did manually build the migrations with the Eloquent syntax prior to running these commands. (Found out about the Blueprint method later...) Could having an already-working database table be problematic?

from generators.

yabbou avatar yabbou commented on August 18, 2024

run the commands in the reverse order than showed in the intro videos:

php artisan backpack:crud Customer
php artisan blueprint:build 

and thank God it worked 😌

from generators.

yabbou avatar yabbou commented on August 18, 2024

Caveat actually: only the Customer models will be created without the error. Any backpack:crud <Model> commands run after php artisan blueprint:build still return the error.

from generators.

pxpm avatar pxpm commented on August 18, 2024

Hello again @yabbou .

Maybe php artisan blueprint:erase before the build command?

from generators.

yabbou avatar yabbou commented on August 18, 2024

It seems that php artisan blueprint:build should be run only after all the Blueprint draft.yml models have been constructed. php artisan blueprint:erase indeed allows me to continue constructing the draft.yml.

I guess I was just assuming that blueprint:build would be run before backpack:build, as in the intro videos.

from generators.

yabbou avatar yabbou commented on August 18, 2024

Strange.

php artisan blueprint:build 
php artisan blueprint:erase

php artisan backpack:crud <Model> 
#repeat for each model, to create their controllers

php artisan blueprint:build 
#then reapply use CrudTrait to each model

Something about the Controller having been created from the blueprint:build enables the rest to be reset in the build -> erase cycle.

from generators.

yabbou avatar yabbou commented on August 18, 2024

Commenting out the automated adding of CrudTrait works. Presumably should not be necessary, but now the regular command call order works:

blueprint:build
backpack:build

CrudModelBackpackCommand.php (line 75):

            // if it does not have CrudTrait, add the trait on the Model

            $classDefinition = 'class '.$this->getNameInput().' extends';

            // foreach ($file_array as $key => $line) {
            //     if (Str::contains($line, $classDefinition)) {
            //         if (Str::endsWith($line, '{')) {
            //             // add the trait on the next
            //             $position = $key + 1;
            //         } elseif ($file_array[$key + 1] == '{') {
            //             // add the trait on the next next line
            //             $position = $key + 2;
            //         }

            //         // keep in mind that the line number shown in IDEs is not
            //         // the same as the array index - arrays start counting from 0,
            //         // IDEs start counting from 1

            //         // add CrudTrait
            //         array_splice($file_array, $position, 0, '    use \\'.$this->crudTrait.';');

            //         // save the file
            //         $this->files->put($path, implode(PHP_EOL, $file_array));

            //         // let the user know what we've done
            //         $this->info('Model already exists! We just added CrudTrait on it.');

            //         return false;
            //     }
            // }

            $this->error('Model already exists! Could not add CrudTrait - please add manually.');

            return false;
        }

I likely moved some file out of place, but I am not sure which one...

from generators.

yabbou avatar yabbou commented on August 18, 2024

Strange as well... only for some models do the Controller's setUpListOperation() and setUpCreateOperation() methods receive auto-generated columns. For exmaple:

Customer.php:

  protected function setupCreateOperation()
    {
        CRUD::setValidation(CustomerRequest::class);

        CRUD::field('primary_customer_id');
        CRUD::field('primary_phone_id');
        CRUD::field('billing_address_id');
        CRUD::field('default_shipping_address_id');
        CRUD::field('name');
        CRUD::field('email');
        CRUD::field('external_c_id');
        CRUD::field('external_c_source');

        /**
         * Fields can be defined using the fluent syntax or array syntax:
         * - CRUD::field('price')->type('number');
         * - CRUD::addField(['name' => 'price', 'type' => 'number'])); 
         */
}

Product.php:

  protected function setupCreateOperation()
    {

        /**
         * Columns can be defined using the fluent syntax or array syntax:
         * - CRUD::column('price')->type('number');
         * - CRUD::addColumn(['name' => 'price', 'type' => 'number']); 
         */
...
}

from generators.

yabbou avatar yabbou commented on August 18, 2024

All the new Controllers have included auto-filled setUpListOperation() and setUpCreateOperation() methods, thank God.

from generators.

wejdanAlahaideb avatar wejdanAlahaideb commented on August 18, 2024

I am having same issue, i have noticed that this happen if I manually deleted the file generated by backpack:crud command

from generators.

pxpm avatar pxpm commented on August 18, 2024

Wouldn't #100 fix this ?

from generators.

yabbou avatar yabbou commented on August 18, 2024

I ran a php artisan backpack:install as an attempt to update my version of Backpack, but I seem to still have the version from before the updates. If it works by you, that could very well be reliable, but how would you recommend updating and testing myself?

from generators.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.