-
Notifications
You must be signed in to change notification settings - Fork 10.9k
/
InteractsWithSession.php
64 lines (53 loc) · 1.12 KB
/
InteractsWithSession.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace Illuminate\Foundation\Testing\Concerns;
trait InteractsWithSession
{
/**
* Set the session to the given array.
*
* @param array $data
* @return $this
*/
public function withSession(array $data)
{
$this->session($data);
return $this;
}
/**
* Set the session to the given array.
*
* @param array $data
* @return $this
*/
public function session(array $data)
{
$this->startSession();
foreach ($data as $key => $value) {
$this->app['session']->put($key, $value);
}
return $this;
}
/**
* Start the session for the application.
*
* @return $this
*/
protected function startSession()
{
if (! $this->app['session']->isStarted()) {
$this->app['session']->start();
}
return $this;
}
/**
* Flush all of the current session data.
*
* @return $this
*/
public function flushSession()
{
$this->startSession();
$this->app['session']->flush();
return $this;
}
}