Cure.php 840 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Cure extends Model
  5. {
  6. protected $table = 'cure';
  7. protected $primaryKey = 'id';
  8. // protected function serializeDate(\DateTimeImmutable $date)
  9. // {
  10. // return $date->format('Y-m-d H:i:s');
  11. // }
  12. const CREATED_AT = 'creation_date';
  13. public static function getList(int $page,int $limit)
  14. {
  15. $offset = ($page - 1) * $limit;
  16. $query = Cure::query()->offset($offset)->limit($limit)->get();
  17. if ($query){
  18. return $query->toArray();
  19. }else{
  20. return [];
  21. }
  22. }
  23. public static function insertData(array $data)
  24. {
  25. return Cure::query()->insert($data);
  26. }
  27. public static function del(int $id)
  28. {
  29. return Cure::query()->where('id', $id)->delete();
  30. }
  31. }