diff --git a/app/Home.php b/app/Home.php index b4769bb..8864e2b 100644 --- a/app/Home.php +++ b/app/Home.php @@ -3,6 +3,7 @@ namespace App; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Str; use Spatie\QueryBuilder\QueryBuilder; @@ -52,4 +53,17 @@ class Home extends Model { return $query->where('garden_surface', '>=', $price); } + + /** + * The "booted" method of the model. + * + * @return void + */ + protected static function booted() + { + // Download images on creation + static::created(static function ($home) { + Artisan::call('app:downloadimage ' . $home->id); + }); + } }