| Conditions | 5 |
| Paths | 4 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | public function translate(string $resource, $key, Locale $locale) |
||
| 13 | { |
||
| 14 | $model = Nova::modelInstanceForKey($resource); |
||
| 15 | |||
| 16 | if (empty($model) || ! ($model instanceof IsTranslatable)) { |
||
| 17 | return redirect()->back(); |
||
| 18 | } |
||
| 19 | |||
| 20 | /** @var \BBSLab\NovaTranslation\Models\Contracts\IsTranslatable $model */ |
||
| 21 | $model = $model->newQuery()->find($key); |
||
| 22 | |||
| 23 | if (empty($model)) { |
||
| 24 | return redirect()->back(); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** @var \BBSLab\NovaTranslation\Models\Contracts\IsTranslatable $translated */ |
||
| 28 | $translated = $model->translate($locale); |
||
| 29 | |||
| 30 | return $translated |
||
| 31 | ? redirect(str_replace('//', '/', $this->redirectToResource($translated))) |
||
| 32 | : redirect()->back(); |
||
| 33 | } |
||
| 34 | |||
| 57 |