2014-11-27 14:01:38 +00:00
|
|
|
<?php
|
|
|
|
|
2014-11-27 16:05:00 +00:00
|
|
|
use Watson\Validating\ValidatingTrait;
|
2014-11-27 14:09:47 +00:00
|
|
|
|
2014-11-27 16:05:00 +00:00
|
|
|
class Service extends Eloquent {
|
|
|
|
use ValidatingTrait;
|
2014-11-27 14:09:47 +00:00
|
|
|
|
2014-11-27 16:05:00 +00:00
|
|
|
protected $rules = [
|
|
|
|
'type' => 'alpha_dash|required',
|
|
|
|
'active' => 'required|in:0,1',
|
|
|
|
'properties' => ''
|
|
|
|
];
|
2014-11-27 14:01:38 +00:00
|
|
|
|
2014-12-20 20:40:48 +00:00
|
|
|
/**
|
|
|
|
* Returns a decoded properties object for the service.
|
|
|
|
* @param string $properties
|
|
|
|
* @return object
|
|
|
|
*/
|
2014-11-27 16:05:00 +00:00
|
|
|
public function getPropertiesAttribute($properties) {
|
|
|
|
return json_decode($properties);
|
|
|
|
}
|
|
|
|
|
2014-12-20 20:40:48 +00:00
|
|
|
/**
|
|
|
|
* Sets the properties attribute which auto encodes to a JSON string.
|
|
|
|
* @param mixed $properties
|
|
|
|
*/
|
2014-11-27 16:05:00 +00:00
|
|
|
public function setPropertiesAttribute($properties) {
|
|
|
|
$this->attributes['properties'] = json_encode($properties);
|
|
|
|
}
|
2014-11-27 22:08:28 +00:00
|
|
|
}
|