Rename component.component to component_id with relationship name change Rename more instances of parent to component Working on Incident Repository Fix Incident seeder component_id is fillable within the model Fix bad relationship Finished Incident repository Added Metric repository Updated tests for new dingo release
36 lines
806 B
PHP
36 lines
806 B
PHP
<?php
|
|
|
|
namespace CachetHQ\Cachet\Repositories\Incident;
|
|
|
|
use CachetHQ\Cachet\Repositories\EloquentRepository;
|
|
use Incident;
|
|
|
|
class EloquentIncidentRepository extends EloquentRepository implements IncidentRepository {
|
|
|
|
protected $model;
|
|
|
|
public function __construct(Incident $model) {
|
|
$this->model = $model;
|
|
}
|
|
|
|
public function create($user_id, array $array) {
|
|
$incident = new $this->model($array);
|
|
$incident->user_id = $user_id;
|
|
|
|
$this->validate($incident)->hasRelationship($incident, 'component');
|
|
|
|
$incident->saveOrFail();
|
|
return $incident;
|
|
}
|
|
|
|
public function update($id, array $array) {
|
|
$incident = $this->model->findOrFail($id);
|
|
$incident->fill($array);
|
|
|
|
$this->validate($incident)->hasRelationship($incident, 'component');
|
|
|
|
$incident->update($array);
|
|
return $incident;
|
|
}
|
|
}
|