CustomFieldValue.php 718 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace App\Model;
  3. use Illuminate\Database\Eloquent\Model;
  4. // 自定义项存储表
  5. class CustomFieldValue extends DataScopeBaseModel
  6. {
  7. protected $guarded = [];
  8. protected $table = "custom_field_values"; //指定表
  9. const CREATED_AT = 'crt_time';
  10. const UPDATED_AT = 'upd_time';
  11. protected $dateFormat = 'U';
  12. const type_one = 1;
  13. const type_two = 2;
  14. const type = [
  15. self::type_one => '文本',
  16. self::type_two => '附件',
  17. ];
  18. public function definition()
  19. {
  20. // 即使你不需要它的数据,whereHas 也要靠这个方法生成 SQL 的 JOIN 或 EXISTS
  21. return $this->belongsTo(CustomFieldDefinitions::class, 'definition_id');
  22. }
  23. }