1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| /**
* send mail to vendor for specific flux or for all.
*
* @retun void
*/
public function handle()
{
try {
// Je récupère le flux du fichier
if (empty($this->argument('idFLux'))) {
$fluxes = VendorFlux::where([
['is_period', 1],
])->get();
} else {
$fluxes[] = VendorFlux::where([
['id_flux', $this->argument('idFLux')],
])->first();
}
// pour tous les flux(fichier) je récupère les différnts produits avec une erreur
foreach ($fluxes as $flux) {
$productsWithErrors = VendorFluxProduct::where([
['errors', '!=', null],
['on_csv', '=', true],
['state', '=', VendorFluxProduct::STATE_NEW],
])
->get();
$vendor = Vendor::where([
['id_vendor', $flux->id_vendor],
])->first();
$user = User::where([
['id_user', $vendor->id_user],
])->first();
// je généère mon mail
Mail::to($user->email)->send(new VendorEmailErrors($user, $productsWithErrors, $flux->url));
}
} catch (Exception $e) {
Log::warning('Problem event for send mail for id_flux'.$e->getMessage());
echo $e->getMessage();
}
} |
Partager