NoticeController.php 825 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\Controller;
  5. use Illuminate\Support\Facades\Redis;
  6. use App\Models;
  7. class NoticeController extends Controller
  8. {
  9. /*
  10. * 公告
  11. */
  12. public function notice(Request $req){
  13. $Notice = new Models\Notice;
  14. $data = $Notice->notice_info();
  15. if(!$data){
  16. return toJson(-1);
  17. }
  18. return toJson(1,'',$data);
  19. }
  20. /*
  21. * 添加系统公告
  22. */
  23. public function redisNotice(array $msg){
  24. foreach($msg as $k => $v){
  25. Redis::rpush('msg',$v);
  26. }
  27. }
  28. /*
  29. * 获取后删除系统公告
  30. */
  31. public function redisPop(){
  32. $msg = Redis::lrange('msg',0,-1);
  33. Redis::ltrim('msg',1,0);
  34. return toJson(1,'',$msg);
  35. }
  36. }