Files
cachet-docker/app/Models/Service.php
2015-03-20 18:30:45 -06:00

54 lines
1.2 KiB
PHP

<?php
namespace CachetHQ\Cachet\Models;
use Illuminate\Database\Eloquent\Model;
use Watson\Validating\ValidatingTrait;
/**
* @property int $id
* @property string $type
* @property int $active
* @property string $properties
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon $deleted_at
*/
class Service extends Model
{
use ValidatingTrait;
/**
* The validation rules.
*
* @var string[]
*/
protected $rules = [
'type' => 'alpha_dash|required',
'active' => 'required|in:0,1',
'properties' => '',
];
/**
* Returns a decoded properties object for the service.
*
* @param string $properties
*
* @return object
*/
public function getPropertiesAttribute($properties)
{
return json_decode($properties);
}
/**
* Sets the properties attribute which auto encodes to a JSON string.
*
* @param mixed $properties
*/
public function setPropertiesAttribute($properties)
{
$this->attributes['properties'] = json_encode($properties);
}
}