Skip to content

Instantly share code, notes, and snippets.

@saeedhajinasiri
Created June 5, 2020 11:58
Show Gist options
  • Save saeedhajinasiri/bbf823325f1b4a61c049f2a7f1ba89d4 to your computer and use it in GitHub Desktop.
Save saeedhajinasiri/bbf823325f1b4a61c049f2a7f1ba89d4 to your computer and use it in GitHub Desktop.
<?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