View file vendor/illuminate/http/Concerns/InteractsWithFlashData.php

File size: 1.34Kb
  1. <?php
  2.  
  3. namespace Illuminate\Http\Concerns;
  4.  
  5. trait InteractsWithFlashData
  6. {
  7. /**
  8. * Retrieve an old input item.
  9. *
  10. * @param string|null $key
  11. * @param string|array|null $default
  12. * @return string|array
  13. */
  14. public function old($key = null, $default = null)
  15. {
  16. return $this->hasSession() ? $this->session()->getOldInput($key, $default) : $default;
  17. }
  18.  
  19. /**
  20. * Flash the input for the current request to the session.
  21. *
  22. * @return void
  23. */
  24. public function flash()
  25. {
  26. $this->session()->flashInput($this->input());
  27. }
  28.  
  29. /**
  30. * Flash only some of the input to the session.
  31. *
  32. * @param array|mixed $keys
  33. * @return void
  34. */
  35. public function flashOnly($keys)
  36. {
  37. $this->session()->flashInput(
  38. $this->only(is_array($keys) ? $keys : func_get_args())
  39. );
  40. }
  41.  
  42. /**
  43. * Flash only some of the input to the session.
  44. *
  45. * @param array|mixed $keys
  46. * @return void
  47. */
  48. public function flashExcept($keys)
  49. {
  50. $this->session()->flashInput(
  51. $this->except(is_array($keys) ? $keys : func_get_args())
  52. );
  53. }
  54.  
  55. /**
  56. * Flush all of the old input from the session.
  57. *
  58. * @return void
  59. */
  60. public function flush()
  61. {
  62. $this->session()->flashInput([]);
  63. }
  64. }