diff --git a/src/Prettus/Repository/Generators/Stubs/repository/eloquent.stub b/src/Prettus/Repository/Generators/Stubs/repository/eloquent.stub index ac152368..d42be32d 100644 --- a/src/Prettus/Repository/Generators/Stubs/repository/eloquent.stub +++ b/src/Prettus/Repository/Generators/Stubs/repository/eloquent.stub @@ -3,6 +3,8 @@ $NAMESPACE$ use Prettus\Repository\Eloquent\BaseRepository; +use Prettus\Repository\Criteria\RequestCriteria; +use $MODEL$; /** * Class $CLASS$RepositoryEloquent @@ -17,7 +19,7 @@ class $CLASS$RepositoryEloquent extends BaseRepository implements $CLASS$Reposit */ public function model() { - return '$MODEL$'; + return $CLASS$::class; } /** @@ -25,6 +27,6 @@ class $CLASS$RepositoryEloquent extends BaseRepository implements $CLASS$Reposit */ public function boot() { - $this->pushCriteria( app('Prettus\Repository\Criteria\RequestCriteria') ); + $this->pushCriteria( app(RequestCriteria::class) ); } -} +} \ No newline at end of file diff --git a/src/Prettus/Repository/Generators/Stubs/transformer/transformer.stub b/src/Prettus/Repository/Generators/Stubs/transformer/transformer.stub index 4c32036b..cd0a5ec6 100644 --- a/src/Prettus/Repository/Generators/Stubs/transformer/transformer.stub +++ b/src/Prettus/Repository/Generators/Stubs/transformer/transformer.stub @@ -3,6 +3,7 @@ $NAMESPACE$ use League\Fractal\TransformerAbstract; +use $MODEL_NAMESPACE$$CLASS$; /** * Class $CLASS$Transformer @@ -17,7 +18,7 @@ class $CLASS$Transformer extends TransformerAbstract * * @return array */ - public function transform(\$CLASS$ $model) { + public function transform($CLASS$ $model) { return [ 'id' => (int)$model->id, @@ -27,4 +28,4 @@ class $CLASS$Transformer extends TransformerAbstract 'updated_at' => $model->updated_at ]; } -} +} \ No newline at end of file diff --git a/src/Prettus/Repository/Generators/TransformerGenerator.php b/src/Prettus/Repository/Generators/TransformerGenerator.php index 73045f98..3ac519ff 100644 --- a/src/Prettus/Repository/Generators/TransformerGenerator.php +++ b/src/Prettus/Repository/Generators/TransformerGenerator.php @@ -44,4 +44,17 @@ public function getPath() { return $this->getBasePath() . '/Transformers/' . $this->getName() . 'Transformer.php'; } + + /** + * Get array replacements. + * + * @return array + */ + public function getReplacements() + { + $modelGenerator = new ModelGenerator(); + return array_merge(parent::getReplacements(),[ + 'model_namespace' => $modelGenerator->getRootNamespace() + ]); + } } \ No newline at end of file