argument('frame'))) throw new \Exception('Frame is not numeric: '.$this->argument('frame')); if (strlen($this->argument('index')) != 1 OR ! preg_match('/^[a-z]$/',$this->argument('index'))) throw new \Exception('Subframe failed validation'); if (! file_exists($this->argument('file'))) throw new \Exception('File not found: '.$this->argument('file')); $mo = Mode::where('name',$this->option('mode'))->firstOrFail(); $o = new Frame; if ($this->option('replace')) { try { $o = $o->where('frame',$this->argument('frame')) ->where('index',$this->argument('index')) ->where('mode_id',$mo->id) ->firstOrFail(); } catch (ModelNotFoundException $e) { $this->error('Page not found to replace: '.$this->argument('frame').$this->argument('index')); die(1); } } else { $o->frame = $this->argument('frame'); $o->index = $this->argument('index'); $o->mode_id = $mo->id; } $o->content = str_replace('\\','\\\\',($this->option('trim')) ? substr(file_get_contents($this->argument('file')),40) : file_get_contents($this->argument('file'))); $o->access = $this->option('access'); $o->public = $this->option('public'); $o->cost = $this->option('cost'); $o->type = $this->option('type'); $o->save(); } }