123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace App\Services\Content;
- use App\Repositories\TaskRepository;
- use Illuminate\Support\Facades\Cache;
- class TaskService
- {
- protected $taskRepository;
-
- public function __construct(TaskRepository $taskRepository)
- {
- $this->taskRepository = $taskRepository;
- }
-
- public function getTask($utype, $type = '')
- {
- $lists = Cache::get('task_list');
- if ($lists === null) {
- $task_lists = $this->taskRepository->all();
- foreach ($task_lists as $k => $v) {
- $lists[$v->utype][$v->t_alias] = $v;
- }
- Cache::put('task_list', $lists, '86400');
- }
- if ($type) {
- return array_get($lists[$utype], $type);
- }
- return $lists[$utype];
- }
- }
|