Remove repositories from the API and switch cipher to rijndael-256

This commit is contained in:
James Brooks
2015-05-23 19:09:24 +01:00
committed by James Brooks
parent d788691006
commit 106c1a034a
24 changed files with 222 additions and 939 deletions
@@ -1,87 +0,0 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Cachet HQ <support@cachethq.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Cachet\Repositories\Metric;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Repositories\EloquentRepository;
class EloquentMetricRepository extends EloquentRepository implements MetricRepository
{
/**
* The eloquent model instance.
*
* @var \CachetHQ\Cachet\Models\Metric
*/
protected $model;
/**
* Create a new eloquent metric repository instance.
*
* @param \CachetHQ\Cachet\Models\Metric $model
*/
public function __construct(Metric $model)
{
$this->model = $model;
}
/**
* Create a new model.
*
* @param array $data
*
* @return \Illuminate\Database\Eloquent\Model
*/
public function create(array $data)
{
$metric = new $this->model($data);
$this->validate($metric);
$metric->saveOrFail();
return $metric;
}
/**
* Update a model by id.
*
* @param int $id
* @param array $data
*
* @return \Illuminate\Database\Eloquent\Model
*/
public function update($id, array $data)
{
$metric = $this->model->findOrFail($id);
$metric->fill($data);
$this->validate($metric);
$metric->update($data);
return $metric;
}
/**
* Returns all metric point models.
*
* @param int $id
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function points($id)
{
$metric = $this->model->findOrFail($id);
return $metric->points;
}
}
@@ -1,61 +0,0 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Cachet HQ <support@cachethq.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Cachet\Repositories\Metric;
interface MetricRepository
{
/**
* Returns all models.
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function all();
/**
* Returns all metric point models.
*
* @param int $id
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function points($id);
/**
* Create a new model.
*
* @param array $data
*
* @return \Illuminate\Database\Eloquent\Model
*/
public function create(array $data);
/**
* Finds a model by id.
*
* @param int $id
*
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
*
* @return \Illuminate\Database\Eloquent\Model
*/
public function findOrFail($id);
/**
* Update a model by id.
*
* @param int $id
* @param array $data
*
* @return \Illuminate\Database\Eloquent\Model
*/
public function update($id, array $data);
}