Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d16d250

Browse files
committed
Add has method to cookie facade.
1 parent f666769 commit d16d250

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/Illuminate/Cookie/CookieJar.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ public function forget($name)
7373
return $this->make($name, null, -2628000);
7474
}
7575

76+
/**
77+
* Determine if a cookie has been queued.
78+
*
79+
* @param string $key
80+
* @return bool
81+
*/
82+
public function hasQueued($key)
83+
{
84+
return ! is_null($this->queued($key));
85+
}
86+
7687
/**
7788
* Get a queued cookie instance.
7889
*

src/Illuminate/Support/Facades/Cookie.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@
55
*/
66
class Cookie extends Facade {
77

8+
/**
9+
* Determine if a cookie exists on the request.
10+
*
11+
* @param string $key
12+
* @return bool
13+
*/
14+
public static function has($key)
15+
{
16+
return ! is_null(static::$app['request']->cookie($key, null)) &&
17+
! static::hasQueued($key);
18+
}
19+
820
/**
921
* Retrieve a cookie from the request.
1022
*

0 commit comments

Comments
 (0)