CastsAttributes.php 898 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Illuminate\Contracts\Database\Eloquent;
  3. use Illuminate\Database\Eloquent\Model;
  4. /**
  5. * @template TGet
  6. * @template TSet
  7. */
  8. interface CastsAttributes
  9. {
  10. /**
  11. * Transform the attribute from the underlying model values.
  12. *
  13. * @param \Illuminate\Database\Eloquent\Model $model
  14. * @param string $key
  15. * @param mixed $value
  16. * @param array<string, mixed> $attributes
  17. * @return TGet|null
  18. */
  19. public function get(Model $model, string $key, mixed $value, array $attributes);
  20. /**
  21. * Transform the attribute to its underlying model values.
  22. *
  23. * @param \Illuminate\Database\Eloquent\Model $model
  24. * @param string $key
  25. * @param TSet|null $value
  26. * @param array<string, mixed> $attributes
  27. * @return mixed
  28. */
  29. public function set(Model $model, string $key, mixed $value, array $attributes);
  30. }