From 0366644c4f12737cf072c09ea1cd06ea242fec7b Mon Sep 17 00:00:00 2001 From: Vincent BRIDIER Date: Thu, 23 Jan 2025 15:35:17 +0100 Subject: [PATCH] fix: Fix check on salarie and customer relation --- app/Http/Controllers/CustomerController.php | 2 +- app/Models/Customers.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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());