| Conditions | 4 |
| Paths | 1 |
| Total Lines | 33 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 17 | public static function boot() |
||
| 18 | { |
||
| 19 | parent::boot(); |
||
| 20 | static::updating(function($model) { |
||
| 21 | $problem = Problem::findOrFail($model->pid); |
||
| 22 | if($model->original['audit'] != $model->audit) { |
||
| 23 | if($model->audit == 1) { |
||
| 24 | // passed |
||
| 25 | sendMessage([ |
||
| 26 | 'sender' => config('app.official_sender'), |
||
| 27 | 'receiver' => $model->uid, |
||
| 28 | 'title' => __('message.solution.accepted.title'), |
||
| 29 | 'type' => 3, |
||
| 30 | 'level' => 5, |
||
| 31 | 'data' => [ |
||
| 32 | 'problem' => [[ |
||
| 33 | 'pcode' => $problem->pcode, |
||
| 34 | 'title' => $problem->title |
||
| 35 | ]] |
||
| 36 | ] |
||
| 37 | ]); |
||
| 38 | } elseif($model->audit == 2) { |
||
| 39 | // declined |
||
| 40 | sendMessage([ |
||
| 41 | 'sender' => config('app.official_sender'), |
||
| 42 | 'receiver' => $model->uid, |
||
| 43 | 'title' => __('message.solution.declined.title'), |
||
| 44 | 'type' => 4, |
||
| 45 | 'level' => 2, |
||
| 46 | 'data' => [ |
||
| 47 | 'problem' => [[ |
||
| 48 | 'pcode' => $problem->pcode, |
||
| 49 | 'title' => $problem->title |
||
| 50 | ]] |
||
| 58 |