123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <?php namespace Laravel;
- class Input {
-
- protected $input;
-
- protected $files;
-
- const old_input = 'laravel_old_input';
-
- public function __construct($input, $files)
- {
- $this->input = $input;
- $this->files = $files;
- }
-
- public function all()
- {
- return array_merge($this->get(), $this->file());
- }
-
- public function has($key)
- {
- return ( ! is_null($this->get($key)) and trim((string) $this->get($key)) !== '');
- }
-
- public function get($key = null, $default = null)
- {
- return Arr::get($this->input, $key, $default);
- }
-
- public function had($key)
- {
- return ( ! is_null($this->old($key)) and trim((string) $this->old($key)) !== '');
- }
-
- public function old($key = null, $default = null)
- {
- if (Config::get('session.driver') == '')
- {
- throw new \Exception('A session driver must be specified in order to access old input.');
- }
- $driver = IoC::container()->core('session');
- return Arr::get($driver->get(Input::old_input, array()), $key, $default);
- }
-
- public function file($key = null, $default = null)
- {
- return Arr::get($this->files, $key, $default);
- }
-
- public function upload($key, $path)
- {
- return array_key_exists($key, $this->files) ? File::upload($key, $path, $this->files) : false;
- }
- }
|