Files
cachet-docker/app/CachetHq/Cachet/Repositories/Component/EloquentComponentRepository.php
2014-11-26 15:00:36 +00:00

27 lines
629 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;
}
}