Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- class Role extends Model
- {
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
- public $fillable = [
- 'name',
- 'description',
- 'permissions'
- ];
- /**
- * Convert permissions to array
- *
- * @param string $value
- * @return array
- */
- public function getPermissionsAttribute($value)
- {
- return json_decode($value, true);
- }
- /**
- * Convert permissions to json.
- *
- * @param string $value
- * @return void
- */
- public function setPermissionsAttribute($value)
- {
- $this->attributes['permissions'] = json_encode($value);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement