Skip to content

Commit

Permalink
Some adjustments to the stub generator. Issue #53
Browse files Browse the repository at this point in the history
  • Loading branch information
Anderson Andrade committed Jun 30, 2015
1 parent 5c961c6 commit 26162d1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
$NAMESPACE$

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use $MODEL$;

/**
* Class $CLASS$RepositoryEloquent
Expand All @@ -17,14 +19,14 @@ class $CLASS$RepositoryEloquent extends BaseRepository implements $CLASS$Reposit
*/
public function model()
{
return '$MODEL$';
return $CLASS$::class;
}

/**
* Boot up the repository, pushing criteria
*/
public function boot()
{
$this->pushCriteria( app('Prettus\Repository\Criteria\RequestCriteria') );
$this->pushCriteria( app(RequestCriteria::class) );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
$NAMESPACE$

use League\Fractal\TransformerAbstract;
use $MODEL_NAMESPACE$$CLASS$;

/**
* Class $CLASS$Transformer
Expand All @@ -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,

Expand All @@ -27,4 +28,4 @@ class $CLASS$Transformer extends TransformerAbstract
'updated_at' => $model->updated_at
];
}
}
}
13 changes: 13 additions & 0 deletions src/Prettus/Repository/Generators/TransformerGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
]);
}
}

0 comments on commit 26162d1

Please sign in to comment.