ProblemRecommend.php 791 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class ProblemRecommend extends Model
  5. {
  6. protected $table = 'problem_recommend';
  7. protected $primaryKey = 'id';
  8. const CREATED_AT = 'creation_date';
  9. public static function getList(int $page,int $limit)
  10. {
  11. $offset = ($page - 1) * $limit;
  12. $query = self::query()->where(['status'=>0])->orderBy('created_at','desc')->offset($offset)->limit($limit)->get();
  13. if ($query){
  14. return $query->toArray();
  15. }else{
  16. return [];
  17. }
  18. }
  19. public static function insertData(array $data)
  20. {
  21. return self::query()->insert($data);
  22. }
  23. public static function del(int $id)
  24. {
  25. return self::query()->where('id', $id)->delete();
  26. }
  27. }