ArticleCategory.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class ArticleCategory extends Model
  5. {
  6. protected $connection = 'mysql';
  7. protected $pk = 'id';
  8. protected $name = 'article_category';
  9. public static function datainitial()
  10. {
  11. $weid = weid();
  12. $data = array('关于我们', '售后流程');
  13. foreach ($data as $key => $vo) {
  14. $updata[$key] = [
  15. 'weid' => $weid,
  16. 'title' => $vo,
  17. 'sort' => $key + 10,
  18. 'status' => 1
  19. ];
  20. }
  21. $mod = new self;
  22. $mod->saveAll($updata);
  23. }
  24. public static function getTitle($id)
  25. {
  26. $data = [];
  27. $data = self::find($id);
  28. if (!empty($data)) {
  29. $data = $data->toArray();
  30. $returndata = $data['title'];
  31. }
  32. return $returndata;
  33. }
  34. public static function getpagearray() {
  35. $data = self::field('id,title')->where(['weid'=>weid(),'status' => 1])
  36. ->order('sort asc')
  37. ->select()->toArray();
  38. foreach ($data as $k => $v) {
  39. $array[$k]['val'] = $v['id'];
  40. $array[$k]['key'] = $v['title'];
  41. }
  42. return $array;
  43. }
  44. }