country = (new Customers())->getIsoCountry($customer->country); }); static::updating(function ($customer) { $customer->country = (new Customers())->getIsoCountry($customer->country); }); } /** * getIsoCountry method * Default is : France * * @param string $country * @return integer */ private function getIsoCountry($country) { $country = trim(ucfirst(strtolower($country))); switch ($country) { case 'Belgique': $country = 56; break; case 'Luxembourg': $country = 442; break; default: $country = 250; } return $country; } /** * Printed Coupons Relation * * @return HasMany */ public function printedCoupons() { return $this->hasMany(PrintedCoupons::class, 'customer_id', 'id'); } /** * Basket model relation * @return HasMany */ public function baskets() { return $this->hasMany(Basket::class, 'customer_id', 'id'); } /** * Panier model relation * @return HasMany */ public function paniers() { return $this->hasMany(Panier::class, 'panier_contactId', 'id'); } }