Cookie.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace Illuminate\Support\Facades;
  3. /**
  4. * @method static \Symfony\Component\HttpFoundation\Cookie make(string $name, string $value, int $minutes = 0, string|null $path = null, string|null $domain = null, bool|null $secure = null, bool $httpOnly = true, bool $raw = false, string|null $sameSite = null)
  5. * @method static \Symfony\Component\HttpFoundation\Cookie forever(string $name, string $value, string|null $path = null, string|null $domain = null, bool|null $secure = null, bool $httpOnly = true, bool $raw = false, string|null $sameSite = null)
  6. * @method static \Symfony\Component\HttpFoundation\Cookie forget(string $name, string|null $path = null, string|null $domain = null)
  7. * @method static bool hasQueued(string $key, string|null $path = null)
  8. * @method static \Symfony\Component\HttpFoundation\Cookie|null queued(string $key, mixed $default = null, string|null $path = null)
  9. * @method static void queue(mixed ...$parameters)
  10. * @method static void expire(string $name, string|null $path = null, string|null $domain = null)
  11. * @method static void unqueue(string $name, string|null $path = null)
  12. * @method static \Illuminate\Cookie\CookieJar setDefaultPathAndDomain(string $path, string|null $domain, bool|null $secure = false, string|null $sameSite = null)
  13. * @method static \Symfony\Component\HttpFoundation\Cookie[] getQueuedCookies()
  14. * @method static \Illuminate\Cookie\CookieJar flushQueuedCookies()
  15. * @method static void macro(string $name, object|callable $macro)
  16. * @method static void mixin(object $mixin, bool $replace = true)
  17. * @method static bool hasMacro(string $name)
  18. * @method static void flushMacros()
  19. *
  20. * @see \Illuminate\Cookie\CookieJar
  21. */
  22. class Cookie extends Facade
  23. {
  24. /**
  25. * Determine if a cookie exists on the request.
  26. *
  27. * @param string $key
  28. * @return bool
  29. */
  30. public static function has($key)
  31. {
  32. return ! is_null(static::$app['request']->cookie($key, null));
  33. }
  34. /**
  35. * Retrieve a cookie from the request.
  36. *
  37. * @param string|null $key
  38. * @param mixed $default
  39. * @return string|array|null
  40. */
  41. public static function get($key = null, $default = null)
  42. {
  43. return static::$app['request']->cookie($key, $default);
  44. }
  45. /**
  46. * Get the registered name of the component.
  47. *
  48. * @return string
  49. */
  50. protected static function getFacadeAccessor()
  51. {
  52. return 'cookie';
  53. }
  54. }