Issue 27 - Add salarie end_date management
This commit is contained in:
parent
b746b1e968
commit
27afc6b120
4 changed files with 31 additions and 3 deletions
|
|
@ -151,10 +151,17 @@ class CustomerController extends Controller
|
|||
/** @var Customers|null */
|
||||
$customer = Customers::where('email', $request->email)->first();
|
||||
|
||||
if ($customer && $customer->isNoLongerEmployed()) {
|
||||
$customer->remember_token = null;
|
||||
$customer->saveOrFail();
|
||||
return back()->withErrors(
|
||||
'Compte bloqué. Veuillez contacter votre RH ou le standard St Laurent au 02 43 62 70 00'
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
/** @var \LDC\LDCCRM\CrmApiV2 */
|
||||
$crm = app('crmAPI');
|
||||
|
||||
// * Ne devrait pas survenir, $crm->login throws ApiError::authFailed()
|
||||
if (!$crm->login($request->email, $request->password)) {
|
||||
// * mauvais identifiants
|
||||
|
|
@ -275,7 +282,7 @@ class CustomerController extends Controller
|
|||
Mail::to($email)->send(new PasswordResetMail($token));
|
||||
return back()->with(
|
||||
'success',
|
||||
__("La procédure pour changer votre mot de passe a été envoyé sur votre email.")
|
||||
__("La procédure pour changer votre mot de passe a été envoyée sur votre email.")
|
||||
);
|
||||
} else {
|
||||
return back()->withErrors(__("Cette adresse email n'est pas enregistrée dans nos services."));
|
||||
|
|
|
|||
|
|
@ -30,6 +30,13 @@ class OrderTunnelController extends Controller
|
|||
*/
|
||||
public function recapOrder()
|
||||
{
|
||||
if (auth()->user()->isNoLongerEmployed()) {
|
||||
auth()->logout();
|
||||
return redirect()->route('auth.connexion')->withErrors(
|
||||
'Compte bloqué. Veuillez contacter votre RH ou le standard St Laurent au 02 43 62 70 00'
|
||||
);
|
||||
}
|
||||
|
||||
$activestep = 1;
|
||||
Cart::instance('panier');
|
||||
$cart = Cart::content();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
|||
use App\Models\Salarie;
|
||||
use LDC\LDCCRM\Exceptions\CrmException;
|
||||
use LDC\LDCCRM\Models\Customer as CrmCustomer;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Customers extends Authenticatable
|
||||
{
|
||||
|
|
@ -113,4 +114,17 @@ class Customers extends Authenticatable
|
|||
return parent::toArray();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if customer is no longer employed
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isNoLongerEmployed()
|
||||
{
|
||||
if (!$this->salarie->end_date) {
|
||||
return false;
|
||||
}
|
||||
return Carbon::parse($this->salarie->end_date)->lessThanOrEqualTo(Carbon::now());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<p class="m-0 me-2">Votre mot de passe a bien été modifié.</p>
|
||||
</div>
|
||||
<div class="text-center mt-2">
|
||||
<a class="btn btn-product rounded-4" href="{{ route('account.dashboard') }}">Voir mon profile</a>
|
||||
<a class="btn btn-product rounded-4" href="{{ route('account.dashboard') }}">Voir mon profil</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue