public static function from_url($url, $force_fetch = false) { if (!$force_fetch) { $i = Image::whereOriginalFileName($url)->first(); if ($i) { return $i; } } $i = new Image(); $i->original_file_name = $url; $i->att = $url; $i->save(); return $i; }
/** * Execute the console command. * * @return mixed */ public function fire() { $images = Image::all(); foreach ($images as $i) { if ($this->option('force') == null && !$i->should_reprocess()) { continue; } echo "Processing {$i->image->url()}\n"; try { $i->image->reprocess(); $i->save(); } catch (FileNotFoundException $e) { echo "\tFile not found."; } } }
/** * Execute the console command. * * @return mixed */ public function fire() { $file = $this->argument('url'); $i = Image::from_url($file, true); echo "Image ID is {$i->id}\n"; }