1 | <?php |
||
33 | trait CrudTrait |
||
34 | { |
||
35 | /** |
||
36 | * Create a new note. |
||
37 | * |
||
38 | * @param array $input |
||
39 | * |
||
40 | * @return $this |
||
41 | */ |
||
42 | 2 | public function createNote(array $input) |
|
43 | { |
||
44 | 2 | $this->body = $input['note_body']; |
|
45 | 2 | $this->project_id = $this->project->id; |
|
46 | 2 | $this->created_by = $this->createdBy->id; |
|
47 | 2 | $this->save(); |
|
48 | |||
49 | // Add to user's activity log |
||
50 | 2 | $this->activity()->save(new Model\User\Activity([ |
|
51 | 2 | 'type_id' => Model\Activity::TYPE_NOTE, |
|
52 | 2 | 'parent_id' => $this->project->id, |
|
53 | 2 | 'user_id' => $this->createdBy->id, |
|
54 | ])); |
||
55 | |||
56 | 2 | return $this; |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * Delete a note. |
||
61 | * |
||
62 | * @return bool|null |
||
63 | * |
||
64 | * @throws \Exception |
||
65 | */ |
||
66 | 1 | public function delete() |
|
72 | } |
||
73 |