-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Improvement] Change CRUD command & route from singular to plural #63
Comments
Agree! I tend to use singular everywhere (why complicate life?) |
Update: I think we've got enough breaking changes as-is. And plenty of people have already installed 4.1 with the singular form. So let's postpone this for 6 months, until Backpack 4.2 - I hope that one will have less breaking changes. |
Hi there! Is this still an issue? No activity in 60 days. I'm going to mark it as stale for now, and close it in 14 days if no further activity occurs. I know you guys are all busy, but if this is important to you please reply or something, so I know not to close it. Thank you! -- |
@tabacitu "But this means we need to be super-sure about both the single and plural name, basically asking both from the user." Laravel's "we can get the singular by stripping the 's' - tag;" won't always work, but again, Str::plural() should handle these cases just fine (starting with singular). I think this means that you wouldn't have to change the user interface either. |
Yeah you're right @joelmellon , it works pretty well in English. And class names, models should be in English anyway. So that should work well! Also note here (TLDR of my comment in Laravel-Backpack/CRUD#3121 (comment)) - we should also split the words by dashes! To end up with |
Hi there! Is this still an issue? No activity in 60 days. I'm going to mark it as stale for now, and close it in 14 days if no further activity occurs. I know you guys are all busy, but if this is important to you please reply or something, so I know not to close it. Thank you! -- |
That's a great idea. Solves the most if not all of the issues here I think. |
Hi there! Is this still an issue? No activity in 60 days. I'm going to mark it as stale for now, and close it in 14 days if no further activity occurs. I know you guys are all busy, but if this is important to you please reply or something, so I know not to close it. Thank you! -- |
bump! |
Hi there! Is this still an issue? No activity in 60 days. I'm going to mark it as stale for now, and close it in 14 days if no further activity occurs. I know you guys are all busy, but if this is important to you please reply or something, so I know not to close it. Thank you! -- |
Hi there! Is this still an issue? No activity in 60 days. I'm going to mark it as stale for now, and close it in 14 days if no further activity occurs. I know you guys are all busy, but if this is important to you please reply or something, so I know not to close it. Thank you! -- |
bump |
Right now we ask people to run
php artisan backpack:crud tag # use singular, not plural
Which is a little counter-intuitive. Since the db table is plural, I think it'll be easier for people to run the plural name instead. We chose to use the singular because, in the past, the Laravel best practice was to use singular for Resource Routes, and for Controller name. Now the best practice is to have plural for resource route (
Route::resource('tags', 'TagController');
) but still singular for Controller name. That's why, I think, in addition to changing the command from singular to plural, we should also change the route. So that it's:But this means we need to be super-sure about both the single and plural name, basically asking both from the user. So maybe instead we should do something like this:
Once you specify the table name (
tags
) we can offer sensible defaults for the rest of the prompts:tags
;tag
;app
folder for any class that extendsModel
that is either calledTag.php
, or has$table = 'tags';
inside it; to see if the dev already has a Model they might want to use;App\Models\Tag.php
This way, you don't have to remember if it's singular or plural, the command-line prompt tells you exactly what it needs. You just need to remember
php artisan backpack:crud
- which is super-easy to remember. Possible alias:php artisan make:crud
. For backwards-compatibility, we should probably keep the "singular" as an OPTIONAL parameter. Or we could leavephp artisan backpack:crud
as-is, and create this new commandphp artisan make:crud
which is more powerful. But I see no point in having both, tbh.To sum up, what I propose we do here:
php artisan backpack:crud
optional;Route::crud('tags', 'TagCrudController');
The text was updated successfully, but these errors were encountered: