/** * Execute the command. */ public function handle() { $template = Template::findOrFail($this->template_id); foreach ($template->commands as $command) { $data = $command->toArray(); $this->project->commands()->create($data); } foreach ($template->variables as $variable) { $data = $variable->toArray(); $this->project->variables()->create($data); } foreach ($template->sharedFiles as $file) { $data = $file->toArray(); $this->project->sharedFiles()->create($data); } foreach ($template->configFiles as $file) { $data = $file->toArray(); $this->project->configFiles()->create($data); } }