diff --git a/resources/stubs/controller.api.stub b/resources/stubs/controller.api.stub deleted file mode 100644 index e11e43a..0000000 --- a/resources/stubs/controller.api.stub +++ /dev/null @@ -1,64 +0,0 @@ -own($user, $dummyModel); + return $this->own($user, ${{ modelVariable }}); } /** - * Determine whether the user can view the collection of DummyModel. + * Determine whether the user can view the collection of {{ model }}. * - * @param \NamespacedDummyUserModel $user - * @return mixed + * @param \{{ namespacedUserModel }} $user + * @return \Illuminate\Auth\Access\Response|bool */ - public function viewAll(DummyUser $user) + public function viewAll({{ user }} $user) { return true; } /** - * Determine whether the user can update the DummyModel. + * Determine whether the user can update the {{ model }}. * - * @param \NamespacedDummyUserModel $user - * @param \NamespacedDummyModel $dummyModel - * @return mixed + * @param \{{ namespacedUserModel }} $user + * @param \{{ namespacedModel }} ${{ modelVariable }} + * @return \Illuminate\Auth\Access\Response|bool */ - public function update(DummyUser $user, DummyModel $dummyModel) + public function update({{ user }} $user, {{ model }} ${{ modelVariable }}) { - return $this->own($user, $dummyModel); + return $this->own($user, ${{ modelVariable }}); } /** - * Determine whether the user can delete the DummyModel. + * Determine whether the user can delete the {{ model }}. * - * @param \NamespacedDummyUserModel $user - * @param \NamespacedDummyModel $dummyModel - * @return mixed + * @param \{{ namespacedUserModel }} $user + * @param \{{ namespacedModel }} ${{ modelVariable }} + * @return \Illuminate\Auth\Access\Response|bool */ - public function delete(DummyUser $user, DummyModel $dummyModel) + public function delete({{ user }} $user, {{ model }} ${{ modelVariable }}) { - return $this->own($user, $dummyModel); + return $this->own($user, ${{ modelVariable }}); } /** - * Determine whether the user owns the DummyModel. + * Determine whether the user owns the {{ model }}. * - * @param \NamespacedDummyUserModel $user - * @param \NamespacedDummyModel $dummyModel - * @return mixed + * @param \{{ namespacedUserModel }} $user + * @param \{{ namespacedModel }} ${{ modelVariable }} + * @return \Illuminate\Auth\Access\Response|bool */ - public function own(DummyUser $user, DummyModel $dummyModel) + public function own({{ user }} $user, {{ model }} ${{ modelVariable }}) { return true; } @@ -81,11 +84,11 @@ class DummyClass extends BasePolicy * This function can be used to add conditions to the query builder, * which will specify the user's ownership of the model for the get collection query of this model * - * @param \App\Models\User $user A user object against which to construct the query. By default, the currently logged in user is used. + * @param \{{ namespacedUserModel }} $user A user object against which to construct the query. By default, the currently logged in user is used. * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Database\Eloquent\Builder|null */ - public function qualifyCollectionQueryWithUser(User $user, $query) + public function qualifyCollectionQueryWithUser({{ user }} $user, $query) { return $query; } diff --git a/src/Console/Commands/Laravel/ControllerMakeCommand.php b/src/Console/Commands/Laravel/ControllerMakeCommand.php index a21548a..4be40c1 100644 --- a/src/Console/Commands/Laravel/ControllerMakeCommand.php +++ b/src/Console/Commands/Laravel/ControllerMakeCommand.php @@ -12,8 +12,10 @@ class ControllerMakeCommand extends \Illuminate\Routing\Console\ControllerMakeCo */ protected function resolveStubPath($stub) { + $boilerplateStub = __DIR__. '/../../../../resources' .$stub; + return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) ? $customPath - : __DIR__. '/../../../../resources' .$stub; + : (file_exists($boilerplateStub) ? $boilerplateStub : parent::resolveStubPath($stub)); } } diff --git a/src/Console/Commands/Laravel/ModelMakeCommand.php b/src/Console/Commands/Laravel/ModelMakeCommand.php index 3585af7..b12df52 100644 --- a/src/Console/Commands/Laravel/ModelMakeCommand.php +++ b/src/Console/Commands/Laravel/ModelMakeCommand.php @@ -12,8 +12,10 @@ class ModelMakeCommand extends \Illuminate\Foundation\Console\ModelMakeCommand */ protected function resolveStubPath($stub) { + $boilerplateStub = __DIR__. '/../../../../resources' .$stub; + return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) ? $customPath - : __DIR__. '/../../../../resources' .$stub; + : (file_exists($boilerplateStub) ? $boilerplateStub : parent::resolveStubPath($stub)); } } diff --git a/src/Console/Commands/Laravel/PolicyMakeCommand.php b/src/Console/Commands/Laravel/PolicyMakeCommand.php index 525bd7f..95bb76d 100644 --- a/src/Console/Commands/Laravel/PolicyMakeCommand.php +++ b/src/Console/Commands/Laravel/PolicyMakeCommand.php @@ -12,8 +12,10 @@ class PolicyMakeCommand extends \Illuminate\Foundation\Console\PolicyMakeCommand */ protected function resolveStubPath($stub) { + $boilerplateStub = __DIR__. '/../../../../resources' .$stub; + return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) ? $customPath - : __DIR__. '/../../../../resources' .$stub; + : (file_exists($boilerplateStub) ? $boilerplateStub : parent::resolveStubPath($stub)); } } diff --git a/src/Console/Commands/Laravel/SeederMakeCommand.php b/src/Console/Commands/Laravel/SeederMakeCommand.php index 9bc7552..f4a328f 100644 --- a/src/Console/Commands/Laravel/SeederMakeCommand.php +++ b/src/Console/Commands/Laravel/SeederMakeCommand.php @@ -12,8 +12,10 @@ class SeederMakeCommand extends \Illuminate\Database\Console\Seeds\SeederMakeCom */ protected function resolveStubPath($stub) { + $boilerplateStub = __DIR__. '/../../../../resources' .$stub; + return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) ? $customPath - : __DIR__. '/../../../../resources' .$stub; + : (file_exists($boilerplateStub) ? $boilerplateStub : parent::resolveStubPath($stub)); } }