public function run() { $pos = 0; foreach ($this->data as $category => $template) { $this->category->create(['title' => $category, 'slug' => str_slug($category), 'template' => $template, 'active' => true, 'position' => $pos]); $pos++; } }
/** * Create a new category * * @param $data * @return mixed */ public function create($data) { $icon = $data['icon']; $category = $this->category->create(['title' => $data['title'], 'slug' => str_slug($data['title']), 'template' => $data['template'] == 'null' ? '' : $data['template'], 'description' => $data['description'], 'position' => $this->category->latestPosition() + 1]); if ($data['icon'] instanceof UploadedFile) { $icon = $this->image->icon($category, $data['icon']); } $category = $this->category->update($category, ['icon' => $icon]); return $category; }