CourseChapter.php 692 B

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