From 1e13d8921b57e75bef5c48a40b804f8f82c11c45 Mon Sep 17 00:00:00 2001 From: Clement Date: Thu, 27 Aug 2020 14:48:42 +0200 Subject: [PATCH] =?UTF-8?q?:sparkles:=20Appelle=20la=20commande=20de=20t?= =?UTF-8?q?=C3=A9l=C3=A9chargement=20d'image=20lors=20de=20l'enregistremen?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Home.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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); + }); + } }