12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace app\admin\model;
- use support\Db;
- use support\Model;
- /**
- * 文章分类
- * Class Users
- * @package app\admin\model
- */
- class NewsCategory extends Model
- {
- /**
- * The table associated with the model.
- *
- * @var string
- */
- protected $table = 'news_category';
- public $timestamps = false;
- /**
- * Notes:获取运费列表
- * @param string $keywords
- * @param int $page
- * @param int $limit
- * @return array
- * User: QJF
- * Date: 2022/9/28
- */
- public static function getCategory(int $page, int $limit,$keywords)
- {
- $list = static::select('*')
- ->when($keywords != '', function ($query) use ($keywords){
- $query->where('category_name', 'like', '%' . $keywords . '%');
- })
- ->orderBy('category_create_time','DESC')
- ->forPage($page, $limit)
- ->get();
- $count = static::when($keywords != '', function ($query) use ($keywords){
- $query->where('category_name', 'like', '%' . $keywords . '%');
- })->count();
- return [$list, $count];
- }
- public function getNewsCreateTimeAttribute($value)
- {
- return date('Y-m-d H:i:s', $value);
- }
- }
|