Article.php 632 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace app\common\model;
  3. class Article extends \think\Model
  4. {
  5. public function createTimeArchive()
  6. {
  7. $create_times = $this->order('create_time desc')->column('create_time');
  8. $timeList = [];
  9. foreach($create_times as $value) {
  10. $yearAndMonth = date("Y-m", $value);
  11. $timeList[] = $yearAndMonth;
  12. }
  13. $timeList = array_unique($timeList);
  14. return $timeList;
  15. }
  16. public static function sort($data)
  17. {
  18. $article = self::find($data['id']);
  19. $article->sort = $data['sort'];
  20. return $article->save();
  21. }
  22. }