$this->option('category'), 'imageHeight' => (int)$this->option('height'), 'imageWidth' => (int)$this->option('width'), 'userId' => $this->option('user') ]; $args = collect($args)->filter(function($value, $key){ return $value !== null && $value !== 0; })->all(); $amount = $this->argument('amount'); if(!$amount) $amount = 1; try { for($i = 0; $i < $amount; $i++) { $mediaFile = app(\App\Services\MediaFileFactoryService::class)->create($args); $this->info("Media file {$mediaFile->id} is generated"); } } catch (\Exception $e) { $this->error($e->getMessage()); } } }