Namespaced models and refactored filters

This commit is contained in:
Graham Campbell
2015-01-02 00:18:19 +00:00
parent 15a6694865
commit 0ccb5e289c
66 changed files with 310 additions and 195 deletions

44
src/Models/Service.php Normal file
View File

@@ -0,0 +1,44 @@
<?php
namespace CachetHQ\Cachet\Models;
use Illuminate\Database\Eloquent\Model;
use Watson\Validating\ValidatingTrait;
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);
}
}