| Conditions | 2 |
| Paths | 2 |
| Total Lines | 23 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 42 | public function handle() |
||
| 43 | { |
||
| 44 | $storyExists = $this->client->get('spaces/' . config('storyblok.space_id') . '/stories/', [ |
||
| 45 | 'with_slug' => $this->argument('slug') |
||
| 46 | ])->getBody()['stories']; |
||
| 47 | |||
| 48 | if (!$storyExists) { |
||
| 49 | $source = json_decode(Storage::get($this->argument('filename')), true); |
||
| 50 | |||
| 51 | $story = [ |
||
| 52 | "story" => [ |
||
| 53 | "name" => $source['story']['name'] . ' (Imported)', |
||
| 54 | "slug" => $this->argument('slug'), |
||
| 55 | "content" => $source['story']['content'], |
||
| 56 | ], |
||
| 57 | "publish" => 1 |
||
| 58 | ]; |
||
| 59 | |||
| 60 | $importedStory = $this->client->post('spaces/' . config('storyblok.space_id') . '/stories/', $story)->getBody()['story']; |
||
| 61 | |||
| 62 | $this->info('Imported into Storyblok: ' . $importedStory['name']); |
||
| 63 | } else { |
||
| 64 | $this->warn('Story already exists for: ' . $this->argument('slug')); |
||
| 65 | } |
||
| 68 |