Skip to content
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

[8.x] Add type option to make controller #36853

Merged
merged 2 commits into from
Apr 2, 2021
Merged

[8.x] Add type option to make controller #36853

merged 2 commits into from
Apr 2, 2021

Conversation

dillingham
Copy link
Contributor

@dillingham dillingham commented Apr 2, 2021

PR enables users to define a custom stub type for controllers.

php artisan make:controller CustomController --type=custom
/stubs/controller.custom.stub

This PR does not change any current behavior except for which file to use.

So options like --model=Post and --parent=Author work exactly the same:

{{ namespacedModel }}
{{ namespacedParentModel }}
App\Models\Post
App\Models\Author

Usage:

This works great for any scenario where you have a slightly unique edge case.

Currently needing it for a repetitive controller format pivot that only has store() and delete()

Note:

Only imperfection is the missing stub exception message:

File does not exist at path /Users/brian/Sites/app-name/framework/src/Illuminate/Routing/Console/stubs/controller.custom.stub

Im happy to add an exception If you would like:

abort_if(! file_exists(base_path("/stubs/controller.{$type}.stub")), 500, "Stub not found: controller.{$type}.stub");

@taylorotwell taylorotwell merged commit 663b5b3 into laravel:8.x Apr 2, 2021
crynobone added a commit to orchestral/canvas that referenced this pull request Apr 13, 2021
Danil42Russia added a commit to Danil42Russia/framework that referenced this pull request Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants