FilesystemFileModel.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. declare(strict_types=1);
  3. namespace SixShop\Filesystem\Model;
  4. use think\Model;
  5. use think\model\concern\SoftDelete;
  6. /**
  7. * Class SixShop\Filesystem\Model\FilesystemFileModel
  8. *
  9. * @property int $category_id 分类id
  10. * @property int $file_size 文件大小
  11. * @property int $id 主键
  12. * @property string $create_time 创建时间
  13. * @property string $delete_time 删除时间
  14. * @property string $file_ext 文件类型
  15. * @property string $file_hash 文件hash
  16. * @property string $file_mine 文件MIME
  17. * @property string $file_name 文件名
  18. * @property string $file_path 文件路径
  19. * @property string $file_url 文件URL
  20. * @property string $name 文件备注名称
  21. * @property string $update_time 更新时间
  22. * @method static \think\db\Query onlyTrashed()
  23. * @method static \think\db\Query withTrashed()
  24. */
  25. class FilesystemFileModel extends Model
  26. {
  27. protected $name = 'extension_filesystem_file';
  28. protected $pk = 'id';
  29. use SoftDelete;
  30. public function searchKeywordAttr($query, $value): void
  31. {
  32. if ($value) {
  33. $query->whereLike('file_name|name', '%' . $value . '%');
  34. }
  35. }
  36. public function searchCategoryIdAttr($query, int $value): void
  37. {
  38. if ($value >= 0) {
  39. $query->where('category_id', $value);
  40. }
  41. }
  42. }