fix: Fix check on salarie and customer relation

This commit is contained in:
Vincent BRIDIER 2025-01-23 15:35:17 +01:00
parent 2da57afa29
commit 0366644c4f
No known key found for this signature in database
GPG key ID: 8571BFA20420D512
2 changed files with 2 additions and 2 deletions

View file

@ -152,7 +152,7 @@ class CustomerController extends Controller
/** @var Customers|null */ /** @var Customers|null */
$customer = Customers::where('email', $request->email)->first(); $customer = Customers::where('email', $request->email)->first();
if ($customer && $customer->isNoLongerEmployed()) { if ($customer and $customer->isNoLongerEmployed()) {
$customer->remember_token = null; $customer->remember_token = null;
$customer->saveOrFail(); $customer->saveOrFail();
return back()->withErrors( return back()->withErrors(

View file

@ -132,7 +132,7 @@ class Customers extends Authenticatable
*/ */
public function isNoLongerEmployed() public function isNoLongerEmployed()
{ {
if (!$this->salarie->end_date) { if (!$this->salarie or !$this->salarie->end_date) {
return false; return false;
} }
return Carbon::parse($this->salarie->end_date)->lessThanOrEqualTo(Carbon::now()); return Carbon::parse($this->salarie->end_date)->lessThanOrEqualTo(Carbon::now());