diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index 2850d9d..8f16e7e 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -152,7 +152,7 @@ class CustomerController extends Controller /** @var Customers|null */ $customer = Customers::where('email', $request->email)->first(); - if ($customer && $customer->isNoLongerEmployed()) { + if ($customer and $customer->isNoLongerEmployed()) { $customer->remember_token = null; $customer->saveOrFail(); return back()->withErrors( diff --git a/app/Models/Customers.php b/app/Models/Customers.php index f941748..96f349f 100644 --- a/app/Models/Customers.php +++ b/app/Models/Customers.php @@ -132,7 +132,7 @@ class Customers extends Authenticatable */ public function isNoLongerEmployed() { - if (!$this->salarie->end_date) { + if (!$this->salarie or !$this->salarie->end_date) { return false; } return Carbon::parse($this->salarie->end_date)->lessThanOrEqualTo(Carbon::now());