*/ public function rules() { return [ 'form' => 'required|array', 'name' => 'required|string|max:60', 'slug' => 'required|string|unique:templates', 'description' => 'required|string|max:2000', 'image_url' => 'required|string', 'questions' => 'array', ]; } public function getTemplate(): Template { $structure = $this->form; foreach ($structure as $key => $val) { if (in_array($key, self::IGNORED_KEYS)) { unset($structure[$key]); } } return new Template([ 'name' => $this->name, 'slug' => $this->slug, 'description' => $this->description, 'image_url' => $this->image_url, 'structure' => $structure, 'questions' => $this->questions ?? [] ]); } }