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

[5.5] Added option to make new model a pivot model #21549

Merged
merged 2 commits into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Illuminate/Foundation/Console/ModelMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ protected function createController()
*/
protected function getStub()
{
if ($this->option('pivot')) {
return __DIR__.'/stubs/pivot.model.stub';
}

return __DIR__.'/stubs/model.stub';
}

Expand Down Expand Up @@ -144,6 +148,8 @@ protected function getOptions()

['migration', 'm', InputOption::VALUE_NONE, 'Create a new migration file for the model.'],

['pivot', 'p', InputOption::VALUE_NONE, 'Indicates if the generated model should be a custom intermediate table model.'],

['resource', 'r', InputOption::VALUE_NONE, 'Indicates if the generated controller should be a resource controller.'],
];
}
Expand Down
10 changes: 10 additions & 0 deletions src/Illuminate/Foundation/Console/stubs/pivot.model.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace DummyNamespace;

use Illuminate\Database\Eloquent\Relations\Pivot;

class DummyClass extends Pivot
{
//
}