123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- /**
- * Created by PhpStorm.
- * User: tandunzhao
- * Date: 2017/12/2
- * Time: 上午11:39
- */
- namespace App\Modules\Notice\Services;
- use App\Modules\Notice\Models\Notice;
- use App\Modules\Notice\Models\NoticeType;
- class NoticeService
- {
- /**
- * 获取通知列表
- * @param string $notice_type_id 可不传
- * @param string $status 可不传 0:正常 -1:删除 ;
- * @return mixed
- */
- public static function getAllNoticeList($notice_type_id = '', $status = '') {
- return Notice::getList($notice_type_id, $status);
- }
- /**
- * 获取简易通知列表
- * @param string $notice_type_id 可不传
- * @param string $status 可不传 0:正常 -1:删除 ;
- * @return mixed
- */
- public static function getSimpleNoticeList($notice_type_id = '', $status = '') {
- return Notice::getSimpleNoticeList($notice_type_id, $status);
- }
- /**
- * 添加通知
- * @param $params
- * @return mixed
- */
- public static function addNotice($params) {
- $data = Notice::create($params);
- return $data;
- }
- /**
- * 获取一个通知
- * @param $noticeId 通知ID
- * @return mixed
- */
- public static function getNotice($noticeId) {
- $data = Notice::getItem($noticeId);
- return $data;
- }
- /**
- * 更新通知
- * @param Notice $notice
- * @return Notice
- */
- public static function updateNotice(Notice $notice) {
- $notice->save();
- return $notice;
- }
- /**
- * 获取通知类型列表
- * @return mixed
- */
- public static function getAllNoticeTypeList() {
- $noticeTypes = NoticeType::all();
- return $noticeTypes;
- }
- /**
- * 判断通知类型名称是否存在
- * @param $name
- * @return bool
- */
- public static function existNoticeTypeName($name) {
- return NoticeType::isNameExist($name);
- }
- /**
- * 保存通知类型列表
- * @param $params
- * @return mixed
- */
- public static function addNoticeType($params) {
- $noticeTypes = NoticeType::create($params);
- return $noticeTypes;
- }
- /**
- * 删除公告类型ID
- * @param $id
- */
- public static function rmNoticeType($id) {
- NoticeType::where('id', $id)->delete();
- }
- }
|