AdminSetupModel.php 1002 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Model\Framework;
  4. use App\Model\Model;
  5. class AdminSetupModel extends Model
  6. {
  7. /**
  8. * The table associated with the model.
  9. *
  10. * @var ?string
  11. */
  12. protected ?string $table = 'admin_setup';
  13. protected ?string $dateFormat = 'U';
  14. /**
  15. * 默认查询字段
  16. *
  17. * @var array|string[]
  18. */
  19. public array $select = [
  20. 'id', 'name', 'table', 'value'
  21. ];
  22. public function __construct(array $attributes = [])
  23. {
  24. parent::__construct($attributes);
  25. $this->is_delete_search = 0;
  26. $this->is_status_search = 0;
  27. }
  28. public function searchTableAttribute($query, $value, array $params): mixed
  29. {
  30. if (empty($value)) {
  31. return $query;
  32. }
  33. return $query->where('table', $value);
  34. }
  35. public function dataValueAttribute($value,$params)
  36. {
  37. $value = !empty($value) ? $value : '{}';
  38. return json_decode($value,true);
  39. }
  40. }