Files
cachet-docker/app/CachetHq/Cachet/Repositories/Component/EloquentComponentRepository.php
2014-11-26 23:20:31 +00:00

29 lines
649 B
PHP

<?php
namespace CachetHQ\Cachet\Repositories\Component;
use CachetHQ\Cachet\Repositories\EloquentRepository;
use Component;
use Exception;
class EloquentComponentRepository extends EloquentRepository implements ComponentRepository {
protected $model;
public function __construct(Component $model) {
$this->model = $model;
}
public function create($user_id, array $array) {
$component = new $this->model($array);
$component->user_id = $user_id;
if ($component->isInvalid()) {
throw new Exception('Invalid model validation', $component->getErrors());
}
$component->saveOrFail();
return $component;
}
}