<?php /** * Created by PhpStorm. * User: Administrator * Date: 2018/11/23 * Time: 17:36 */ namespace App\Services\Content; use App\Repositories\TaskRepository; use Illuminate\Support\Facades\Cache; class TaskService { protected $taskRepository; /** * TaskService constructor. * @param $reportRepository */ 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]; } }