public function run() { $data = (require_once 'partners.php'); $path = "./storage/app/media/partners"; $fileData = $this->fillArrayWithFileNodes(new \DirectoryIterator($path), ["jpg", "png", "svg"]); // print_r($fileData); foreach ($data as $key => $model) { if (array_key_exists('category', $model)) { $category = $model['category']; $_category = Category::where('name', '=', $category)->first(); if (is_null($_category)) { $_category = Category::create(['name' => $category]); } $model['category'] = $_category; } $model = $this->createModel('Abnmt\\TheaterPartners\\Models\\Partner', $model); $this->assignImages($model, $fileData); } }
public function getCategoryOptions() { return CategoryModel::orderBy('name')->lists('name', 'slug'); }