Comments (19)
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.
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.
@yabbou you'll need to run
composer update backpack/crud
to update Backpack CRUDcomposer update backpack/generators
to update Backpack Generators
Please give it a try and let us know the result 🙌
from generators.
@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.
@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.
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.
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.
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.
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.
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.
Hello again @yabbou .
Maybe php artisan blueprint:erase
before the build command?
from generators.
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.
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.
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.
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.
All the new Controllers have included auto-filled setUpListOperation()
and setUpCreateOperation()
methods, thank God.
from generators.
I am having same issue, i have noticed that this happen if I manually deleted the file generated by backpack:crud command
from generators.
Wouldn't #100 fix this ?
from generators.
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)
- Class 'Backpack\Generators\GeneratorsServiceProvider' not found HOT 3
- created_at is the first generated field and column HOT 1
- [improvement] refactor the way we validate that file is a model HOT 2
- `php artisan backpack:crud` output is now messy HOT 3
- Create a `php artisan backpack:button` command HOT 3
- Add optional flags to `php artisan backpack:crud` HOT 4
- Command to create a new page: HOT 12
- Echo file paths for PHP classes after `php artisan backpack:crud`
- Method Illuminate\Support\Stringable::lcfirst does not exist. HOT 6
- backpack:crud-controller throw SQL error HOT 4
- backpack:crud SomeEntity throws an error in mongodb
- `php artisan backpack:build` on our demo highlights a bunch of minor problems HOT 2
- [bug] generating nested controllers and models HOT 3
- "Backpack\Generators\Services\BackpackCommand contains 1 abstract method" after update HOT 3
- Issue about abstract class HOT 4
- PHP 8.2 deprecation warning in PageBackpackCommand HOT 2
- In L10 it fails adding CrudTrait HOT 2
- Add --force arg to backpack:crud command HOT 3
- [v6] Remove fluent and array syntax comments from generated CrudControllers HOT 1
- 3.3.16 Method Illuminate\Support\Stringable::value does not exist on `php artisan backpack:build` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from generators.