FileStorageConfig.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace App\Module\File\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. /**
  5. * field start
  6. * @property int $id 主键
  7. * @property string $name 存储磁盘名称,唯一
  8. * @property string $driver 存储驱动(local, s3, oss等)
  9. * @property string $config 配置值,JSON格式
  10. * @property string $description 配置描述
  11. * @property int $is_default 是否默认存储,1表示是,0表示否
  12. * @property int $is_temp 是否用于临时存储,1表示是,0表示否
  13. * @property int $status 状态:1-启用,0-禁用
  14. * @property string $env 环境(development, testing, production)
  15. * @property \Carbon\Carbon $created_at 创建时间
  16. * @property \Carbon\Carbon $updated_at 更新时间
  17. * @property int $created_by 创建人ID
  18. * @property int $updated_by 更新人ID
  19. * field end
  20. */
  21. class FileStorageConfig extends Model
  22. {
  23. /**
  24. * 表名
  25. */
  26. protected $table = 'file_storage_configs';
  27. /**
  28. * 主键
  29. */
  30. protected $primaryKey = 'id';
  31. /**
  32. * 可批量赋值的字段
  33. */
  34. protected $fillable = [
  35. 'name',
  36. 'driver',
  37. 'config',
  38. 'description',
  39. 'is_default',
  40. 'is_temp',
  41. 'status',
  42. 'env',
  43. 'created_by',
  44. 'updated_by'
  45. ];
  46. /**
  47. * 类型转换
  48. */
  49. protected $casts = [
  50. 'config' => 'array',
  51. 'is_default' => 'boolean',
  52. 'is_temp' => 'boolean',
  53. 'status' => 'boolean'
  54. ];
  55. /**
  56. * 自动维护时间戳
  57. */
  58. public $timestamps = true;
  59. /**
  60. * 配置变更历史
  61. */
  62. public function histories()
  63. {
  64. return $this->hasMany(FileStorageConfigHistory::class, 'config_id');
  65. }
  66. }