| Total Complexity | 7 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | class MachineService implements MachineServiceContract |
||
| 18 | { |
||
| 19 | public function allByUserId($userId) |
||
| 20 | { |
||
| 21 | return Machine::where('user_id', $userId)->get(); |
||
| 22 | } |
||
| 23 | |||
| 24 | public function find($id): ?Machine |
||
| 25 | { |
||
| 26 | if ($id instanceof Machine) |
||
| 27 | return $id; |
||
| 28 | return Machine::find($id); |
||
| 29 | } |
||
| 30 | |||
| 31 | public function update($id, $data): Machine |
||
| 32 | { |
||
| 33 | $machine = $this->find($id); |
||
| 34 | $machine->update($data); |
||
| 35 | event(new MachineUpdatedEvent($machine)); |
||
| 36 | return $machine; |
||
| 37 | } |
||
| 38 | |||
| 39 | public function create($data): Machine |
||
| 40 | { |
||
| 41 | $machine = Machine::create($data); |
||
| 42 | event(new MachineRegisteredEvent($machine)); |
||
| 43 | |||
| 44 | return $machine; |
||
| 45 | } |
||
| 46 | |||
| 47 | public function delete($id): bool |
||
| 48 | { |
||
| 49 | return Machine::destroy($id); |
||
|
|
|||
| 50 | } |
||
| 51 | |||
| 52 | public function heartbeat($id, $data): void |
||
| 58 | ]); |
||
| 59 | } |
||
| 60 | |||
| 61 | |||
| 62 | } |
||
| 63 |