*/ public function rules() { $slugRule = ''; if($this->id){ $slugRule = ','.$this->id; } return [ 'form' => 'required|array', 'publicly_listed' => 'boolean', 'name' => 'required|string|max:60', 'slug' => 'required|string|alpha_dash|unique:templates,slug'.$slugRule, 'short_description' => 'required|string|max:1000', 'description' => 'required|string', 'image_url' => 'required|string', 'types' => 'nullable|array', 'industries' => 'nullable|array', 'related_templates' => 'nullable|array', '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([ 'publicly_listed' => $this->publicly_listed, 'name' => $this->name, 'slug' => $this->slug, 'short_description' => $this->short_description, 'description' => $this->description, 'image_url' => $this->image_url, 'structure' => $structure, 'types' => $this->types ?? [], 'industries' => $this->industries ?? [], 'related_templates' => $this->related_templates ?? [], 'questions' => $this->questions ?? [] ]); } }