Created
June 5, 2020 11:58
-
-
Save saeedhajinasiri/bbf823325f1b4a61c049f2a7f1ba89d4 to your computer and use it in GitHub Desktop.
This file contains 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 | |
/** | |
* Make sure that we get an array from JSON string | |
* | |
* @param $value | |
* @return array | |
*/ | |
public function getSettingsAttribute($value) { | |
return json_decode($value, true); | |
} | |
/** | |
* Encode an array to a JSON string | |
* | |
* @param $value | |
*/ | |
public function setSettingsAttribute($value) | |
{ | |
$this->attributes['settings'] = json_encode($value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment