1 | <?php |
||
20 | abstract class RepositoryUpdater |
||
21 | { |
||
22 | use LoggedUser; |
||
23 | |||
24 | /** |
||
25 | * @var Model |
||
26 | */ |
||
27 | protected $model; |
||
28 | |||
29 | /** |
||
30 | * @var User |
||
31 | */ |
||
32 | protected $user; |
||
33 | |||
34 | public function __construct(Model $model) |
||
38 | |||
39 | /** |
||
40 | * Proxy to model save method. |
||
41 | * |
||
42 | * @param array $options |
||
43 | * |
||
44 | * @return bool |
||
45 | */ |
||
46 | public function save(array $options = []) |
||
50 | |||
51 | /** |
||
52 | * Proxy to model delete method. |
||
53 | * |
||
54 | * @return bool|null |
||
55 | */ |
||
56 | public function delete() |
||
60 | |||
61 | /** |
||
62 | * Proxy to model save method. |
||
63 | * |
||
64 | * @param array $data |
||
65 | * |
||
66 | * @return mixed |
||
67 | */ |
||
68 | public function create(array $data) |
||
74 | |||
75 | /** |
||
76 | * Proxy to model update method. |
||
77 | * |
||
78 | * @param array $attributes |
||
79 | * |
||
80 | * @return mixed |
||
81 | */ |
||
82 | public function update(array $attributes = []) |
||
86 | |||
87 | /** |
||
88 | * Execute method inside a db transaction. |
||
89 | * |
||
90 | * @param string $method |
||
91 | * |
||
92 | * @return mixed |
||
93 | */ |
||
94 | protected function transaction($method) |
||
100 | |||
101 | /** |
||
102 | * Save record into activity() relation. |
||
103 | * |
||
104 | * @param array $input |
||
105 | * |
||
106 | * @return mixed |
||
107 | */ |
||
108 | protected function saveToActivity(array $input) |
||
112 | |||
113 | /** |
||
114 | * Save record into activities() relation. |
||
115 | * |
||
116 | * @param array $input |
||
117 | * |
||
118 | * @return mixed |
||
119 | */ |
||
120 | protected function saveToActivities(array $input) |
||
124 | |||
125 | /** |
||
126 | * Return the project storage disk. |
||
127 | * |
||
128 | * @param Project $project |
||
129 | * |
||
130 | * @return string |
||
131 | */ |
||
132 | protected function getProjectStorage(Project $project) |
||
136 | |||
137 | /** |
||
138 | * Remove project storage disk (directory). |
||
139 | * |
||
140 | * @param Project $project |
||
141 | * |
||
142 | * @return void |
||
143 | */ |
||
144 | protected function removeProjectStorage(Project $project) |
||
151 | |||
152 | /** |
||
153 | * Return path to an upload directory in the project storage. |
||
154 | * |
||
155 | * @param Project|int $projectOrId |
||
156 | * @param string $token |
||
157 | * |
||
158 | * @return string |
||
159 | */ |
||
160 | protected function getUploadStorage($projectOrId, $token) |
||
168 | |||
169 | /** |
||
170 | * Set relations from an array of values. |
||
171 | * |
||
172 | * @param array $relations |
||
173 | * |
||
174 | * @return void |
||
175 | */ |
||
176 | protected function setModelRelations(array $relations) |
||
184 | |||
185 | /** |
||
186 | * Set the user object of the user who is modifying the Eloquent model. |
||
187 | * |
||
188 | * @param User|null $user |
||
189 | * |
||
190 | * @return $this |
||
191 | */ |
||
192 | public function setUser(User $user = null) |
||
200 | } |
||
201 |