1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace App\Repositories;
- use App\Models\EmailTemplate;
- use Prettus\Repository\Eloquent\BaseRepository;
- use Prettus\Repository\Criteria\RequestCriteria;
- /**
- * Class EmailTemplateRepository.
- *
- * @package namespace App\Repositories;
- */
- class EmailTemplateRepository extends BaseRepository
- {
- /**
- * Specify Model class name
- *
- * @return string
- */
- public function model()
- {
- return EmailTemplate::class;
- }
-
- /**
- * Boot up the repository, pushing criteria
- */
- public function boot()
- {
- $this->pushCriteria(app(RequestCriteria::class));
- }
- /**
- * 获得短信模板
- * @param string $alias
- * @param array $titleParams
- * @param array $contentParams
- * @return EmailTemplate
- */
- public function getTemplate(string $alias, array $titleParams = [], array $contentParams = [])
- {
- $template=$this->model->where('alias', $alias)->first();
- if (!empty($titleParams)) {
- $template->title=render_template($template->title, $titleParams);
- }
- if (!empty($contentParams)) {
- $template->value=render_template($template->value, $contentParams);
- }
- return $template;
- }
-
- }
|