Last active
January 21, 2020 22:28
-
-
Save anthonyholmes/608be72d1914fad23885 to your computer and use it in GitHub Desktop.
Parse Session Driver for Laravel 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Parse\ParseStorageInterface; | |
class ParseLaravelSessionStorage implements ParseStorageInterface | |
{ | |
/** | |
* Parse will store its values in a specific key. | |
* | |
* @var string | |
*/ | |
private $storageKey = 'parseData'; | |
public function __construct() | |
{ | |
} | |
public function set($key, $value) | |
{ | |
\Session::put($this->storageKey . '.' . $key, $value); | |
} | |
public function remove($key) | |
{ | |
\Session::forget($this->storageKey . '.' . $key); | |
} | |
public function get($key) | |
{ | |
if (\Session::has($this->storageKey . '.' . $key)) { | |
return \Session::get($this->storageKey . '.' . $key); | |
} | |
return; | |
} | |
public function clear() | |
{ | |
\Session::forget($this->storageKey); | |
} | |
public function save() | |
{ | |
// No action required. PHP handles persistence for $_SESSION. | |
return; | |
} | |
public function getKeys() | |
{ | |
return array_keys(\Session::get($this->storageKey)); | |
} | |
public function getAll() | |
{ | |
return \Session::get($this->storageKey); | |
} | |
} |
awesome this work
use Parse\ParseStorageInterface;
Thank you
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do I implement this class in my project ?