Normalize
- add phpcs - fix php standards - fix Laravel standards - normalize tables names
This commit is contained in:
parent
db9255c375
commit
2e99623428
47 changed files with 8423 additions and 270 deletions
|
|
@ -21,7 +21,8 @@ class DeleteUnconfirmedCustomers extends Command
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = "Delete the customers that haven't confirmed their acocunt within 24 hours after the registeration.";
|
||||
protected $description = "Delete the customers that haven't confirmed " .
|
||||
"their acocunt within 24 hours after the registeration.";
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
|
|
@ -41,7 +42,7 @@ class DeleteUnconfirmedCustomers extends Command
|
|||
public function handle()
|
||||
{
|
||||
$customersLogins = CustomerLogin::where([['status', 0], ['created_at', '<', Carbon::now()->subDay(1)]])->get();
|
||||
foreach($customersLogins as $customerLogin) {
|
||||
foreach ($customersLogins as $customerLogin) {
|
||||
// Si non activé et créer il y a plus d'un jour : Suppression
|
||||
$customerLogin->customer->infos()->where('brand_id', $customerLogin->brand_id)->first()->delete();
|
||||
// On récupère son id pour le cas ou on doit le supprimer complètement après
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class Kernel extends ConsoleKernel
|
|||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
$this->load(__DIR__ . '/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,14 @@ class ArcadiaController extends Controller
|
|||
'type' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails())
|
||||
return new StatusResource(['status' => 'KO', 'code' => 201, 'message' => 'Error on required fields.', 'errors' => $validator->errors()]);
|
||||
if ($validator->fails()) {
|
||||
return new StatusResource([
|
||||
'status' => 'KO',
|
||||
'code' => 201,
|
||||
'message' => 'Error on required fields.',
|
||||
'errors' => $validator->errors()
|
||||
]);
|
||||
}
|
||||
|
||||
$brandId = $request->brand_id;
|
||||
$crmId = $request->crm_id;
|
||||
|
|
@ -32,104 +38,132 @@ class ArcadiaController extends Controller
|
|||
$type = $request->type;
|
||||
|
||||
$customer = Customer::where('id', $crmId)->first();
|
||||
if (!$customer)
|
||||
if (!$customer) {
|
||||
return new StatusResource(['status' => 'KO', 'code' => 202, 'message' => 'User not found.']);
|
||||
|
||||
$customerInfos = $customer->infos()->where('brand_id', $brandId)->first();
|
||||
|
||||
if (!$customerInfos)
|
||||
return new StatusResource(['status' => 'KO', 'code' => 202, 'message' => 'User not found.']);
|
||||
|
||||
$check = $this->checkRequiredFields($fields, $type);
|
||||
if ($check['status'] !== 'OK')
|
||||
return new StatusResource($check);
|
||||
|
||||
$xml = $this->makeXML($fields, $type, $customer, $customerInfos);
|
||||
|
||||
try {
|
||||
Storage::disk('arcadia')->put(date ("Ymd_His") . ".xml", $xml);
|
||||
return new StatusResource(['status' => 'OK']);
|
||||
}catch (\Exception $e){
|
||||
Log::critical("ARCADIA XML CREATION FAILED : " . $e->getMessage());
|
||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new CourrierArcadiaError("ARCADIA XML CREATION FAILED", "Une erreur est survenue lors de la création du fichier XML : " . $e->getMessage(), $xml));
|
||||
return new StatusResource(['status' => 'KO', 'code' => 204, 'message' => 'Arcadia XML Creation failed.']);
|
||||
}
|
||||
|
||||
$CustomerInfo = $customer->infos()->where('brand_id', $brandId)->first();
|
||||
|
||||
if (!$CustomerInfo) {
|
||||
return new StatusResource(['status' => 'KO', 'code' => 202, 'message' => 'User not found.']);
|
||||
}
|
||||
|
||||
$check = $this->checkRequiredFields($fields, $type);
|
||||
if ($check['status'] !== 'OK') {
|
||||
return new StatusResource($check);
|
||||
}
|
||||
|
||||
$xml = $this->makeXML($fields, $type, $customer, $CustomerInfo);
|
||||
|
||||
try {
|
||||
Storage::disk('arcadia')->put(date("Ymd_His") . ".xml", $xml);
|
||||
return new StatusResource(['status' => 'OK']);
|
||||
} catch (\Exception $e) {
|
||||
Log::critical("ARCADIA XML CREATION FAILED : " . $e->getMessage());
|
||||
Mail::to(config('mail.MAIL_ADMIN'))
|
||||
->send(new CourrierArcadiaError(
|
||||
"ARCADIA XML CREATION FAILED",
|
||||
"Une erreur est survenue lors de la création du fichier XML : " . $e->getMessage(),
|
||||
$xml
|
||||
));
|
||||
return new StatusResource(['status' => 'KO', 'code' => 204, 'message' => 'Arcadia XML Creation failed.']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function checkRequiredFields($fields, $type)
|
||||
{
|
||||
$errors = [];
|
||||
|
||||
$key = array_search('operation', array_column($fields->root, 'fieldName'));
|
||||
if ($key === false)
|
||||
if ($key === false) {
|
||||
$errors[] = ['field' => 'operation', 'error' => 'required'];
|
||||
}
|
||||
|
||||
$key = array_search('support_code', array_column($fields->orderLine, 'fieldName'));
|
||||
if ($key === false)
|
||||
if ($key === false) {
|
||||
$errors[] = ['field' => 'support_code', 'error' => 'required'];
|
||||
}
|
||||
|
||||
$key = array_search('label_type_support', array_column($fields->orderLine, 'fieldName'));
|
||||
if ($key === false)
|
||||
if ($key === false) {
|
||||
$errors[] = ['field' => 'label_type_support', 'error' => 'required'];
|
||||
}
|
||||
|
||||
$key = array_search('order_date', array_column($fields->root, 'fieldName'));
|
||||
if ($key === false)
|
||||
if ($key === false) {
|
||||
$errors[] = ['field' => 'order_date', 'error' => 'required'];
|
||||
}
|
||||
|
||||
if (!preg_match("/^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$/", $fields->root[$key]->fieldValue)) {
|
||||
$regex = join('', [
|
||||
'/^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|',
|
||||
'((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))',
|
||||
'|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]',
|
||||
'|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$/'
|
||||
]);
|
||||
if (!preg_match($regex, $fields->root[$key]->fieldValue)) {
|
||||
$errors[] = ['field' => 'order_date', 'error' => 'format must be DD/MM/YYYY'];
|
||||
}
|
||||
|
||||
if ($type === 'default'){
|
||||
|
||||
if ($type === 'default') {
|
||||
$key = array_search('order_num', array_column($fields->root, 'fieldName'));
|
||||
if ($key === false)
|
||||
if ($key === false) {
|
||||
$errors[] = ['field' => 'order_num', 'error' => 'required for default type'];
|
||||
}
|
||||
|
||||
if (!is_numeric($fields->root[$key]->fieldValue) || strlen($fields->root[$key]->fieldValue) !== 9)
|
||||
if (!is_numeric($fields->root[$key]->fieldValue) || strlen($fields->root[$key]->fieldValue) !== 9) {
|
||||
$errors[] = ['field' => 'order_num', 'error' => 'format must be 9 numeric characters'];
|
||||
}
|
||||
|
||||
$key = array_search('state_order_cb', array_column($fields->root, 'fieldName'));
|
||||
if ($key === false)
|
||||
if ($key === false) {
|
||||
$errors[] = ['field' => 'state_order_cb', 'error' => 'required for default type'];
|
||||
}
|
||||
|
||||
if ($fields->root[$key]->fieldValue !== 1 && $fields->root[$key]->fieldValue !== 'Null')
|
||||
if ($fields->root[$key]->fieldValue !== 1 && $fields->root[$key]->fieldValue !== 'Null') {
|
||||
$errors[] = ['field' => 'state_order_cb', 'error' => 'value must be 1 or Null (Yes Null not NULL)'];
|
||||
}
|
||||
|
||||
$orderCB = $fields->root[$key]->fieldValue;
|
||||
|
||||
$key = array_search('state_order_check', array_column($fields->root, 'fieldName'));
|
||||
if ($key === false)
|
||||
if ($key === false) {
|
||||
$errors[] = ['field' => 'state_order_check', 'error' => 'required for default type'];
|
||||
}
|
||||
|
||||
if ($fields->root[$key]->fieldValue !== 1 && $fields->root[$key]->fieldValue !== 'Null')
|
||||
if ($fields->root[$key]->fieldValue !== 1 && $fields->root[$key]->fieldValue !== 'Null') {
|
||||
$errors[] = ['field' => 'state_order_check', 'error' => 'value must be 1 or Null (Yes Null not NULL)'];
|
||||
}
|
||||
|
||||
$orderCheck = $fields->root[$key]->fieldValue;
|
||||
|
||||
if ($orderCB === $orderCheck)
|
||||
$errors[] = ['field' => 'state_order', 'error' => 'state_order_cb and state_order_check values must be different'];
|
||||
if ($orderCB === $orderCheck) {
|
||||
$errors[] = [
|
||||
'field' => 'state_order',
|
||||
'error' => 'state_order_cb and state_order_check values must be different'
|
||||
];
|
||||
}
|
||||
|
||||
$key = array_search('package_unit_weight', array_column($fields->orderLine, 'fieldName'));
|
||||
if ($key === false)
|
||||
if ($key === false) {
|
||||
$errors[] = ['field' => 'package_unit_weight', 'error' => 'required for default type'];
|
||||
|
||||
}elseif ($type === 'game'){
|
||||
|
||||
}
|
||||
} elseif ($type === 'game') {
|
||||
$key = array_search('code_unique', array_column($fields->orderLine, 'fieldName'));
|
||||
if ($key === false)
|
||||
if ($key === false) {
|
||||
$errors[] = ['field' => 'code_unique', 'error' => 'required for game type'];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($errors))
|
||||
if (!empty($errors)) {
|
||||
return ['status' => 'NOK', 'code' => 203, 'message' => $errors];
|
||||
}
|
||||
|
||||
return ['status' => 'OK'];
|
||||
}
|
||||
|
||||
private function makeXML($fields, $type, $customer, $customerInfos)
|
||||
private function makeXML($fields, $type, $customer, $CustomerInfo)
|
||||
{
|
||||
$pivot = [
|
||||
'order_num' => 'Num_Commande', // required if type = default - format 9 numeric characters
|
||||
|
|
@ -141,12 +175,14 @@ class ArcadiaController extends Controller
|
|||
'qty' => 'Quantite',
|
||||
'code_on_pack' => 'Code_on_Pack',
|
||||
'code_unique' => 'Code_Unique', // required if type = game
|
||||
'state_order_cb' => 'Etat_Commande_CB', // required if type = default - format 1 ou Null (oui Null et pas NULL)
|
||||
'state_order_check' => 'Etat_Commande_Cheque', // required if type = default - format 1 ou Null (oui Null et pas NULL)
|
||||
// required if type = default - format 1 ou Null (oui Null et pas NULL)
|
||||
'state_order_cb' => 'Etat_Commande_CB',
|
||||
// required if type = default - format 1 ou Null (oui Null et pas NULL)
|
||||
'state_order_check' => 'Etat_Commande_Cheque',
|
||||
|
||||
];
|
||||
|
||||
$dom = new DOMDocument('1.0','UTF-8');
|
||||
$dom = new DOMDocument('1.0', 'UTF-8');
|
||||
$dom->formatOutput = true;
|
||||
|
||||
$root = $dom->createElement('export_arcadia');
|
||||
|
|
@ -154,59 +190,99 @@ class ArcadiaController extends Controller
|
|||
$order = $root->appendChild($dom->createElement('Commande'));
|
||||
|
||||
$key = array_search('order_num', array_column($fields->root, 'fieldName'));
|
||||
if ($key === false)
|
||||
if ($key === false) {
|
||||
$order->appendChild($dom->createElement('Num_Commande'));
|
||||
else
|
||||
} else {
|
||||
$order->appendChild($dom->createElement('Num_Commande', $fields->root[$key]->fieldValue));
|
||||
}
|
||||
|
||||
foreach ($fields->root as $value){
|
||||
if (isset($pivot[$value->fieldName]) && $value->fieldName !== 'state_order_cb' && $value->fieldName !== 'state_order_check' && $value->fieldName !== 'order_num')
|
||||
foreach ($fields->root as $value) {
|
||||
// phpcs:ignore PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace
|
||||
if (
|
||||
isset($pivot[$value->fieldName]) && $value->fieldName !== 'state_order_cb' &&
|
||||
$value->fieldName !== 'state_order_check' && $value->fieldName !== 'order_num'
|
||||
) {
|
||||
$order->appendChild($dom->createElement($pivot[$value->fieldName], $value->fieldValue));
|
||||
}
|
||||
}
|
||||
|
||||
if ($type === 'default') {
|
||||
$key = array_search('state_order_cb', array_column($fields->root, 'fieldName'));
|
||||
if ($key)
|
||||
if ($key) {
|
||||
$order->appendChild($dom->createElement('Etat_Commande_CB', $fields->root[$key]->fieldValue));
|
||||
}
|
||||
|
||||
$key = array_search('state_order_check', array_column($fields->root, 'fieldName'));
|
||||
if ($key)
|
||||
if ($key) {
|
||||
$order->appendChild($dom->createElement('Etat_Commande_Cheque', $fields->root[$key]->fieldValue));
|
||||
}
|
||||
}
|
||||
|
||||
$order->appendChild($dom->createElement('Email_conso'))->appendChild($dom->createCDATASection( "$customer->email"));
|
||||
$order->appendChild($dom->createElement('Civilite'));
|
||||
$order->appendChild($dom->createElement('Nom'))->appendChild($dom->createCDATASection( "$customerInfos->lastname"));
|
||||
$order->appendChild($dom->createElement('Prenom'))->appendChild($dom->createCDATASection( "$customerInfos->firstname"));
|
||||
$order->appendChild($dom->createElement('Adresse'))->appendChild($dom->createCDATASection( "$customerInfos->address"));
|
||||
$order->appendChild($dom->createElement('Adresse_Complementaire'))->appendChild($dom->createCDATASection( "$customerInfos->address2"));
|
||||
$order->appendChild($dom->createElement('CP'))->appendChild($dom->createCDATASection( "$customerInfos->postcode"));
|
||||
$order->appendChild($dom->createElement('Ville'))->appendChild($dom->createCDATASection( "$customerInfos->city"));
|
||||
$order->appendChild($dom->createElement('Telephone'))->appendChild($dom->createCDATASection( "$customerInfos->phone"));
|
||||
$order->appendChild(
|
||||
$dom->createElement('Email_conso')
|
||||
)->appendChild($dom->createCDATASection("$customer->email"));
|
||||
$order->appendChild(
|
||||
$dom->createElement('Civilite')
|
||||
);
|
||||
$order->appendChild(
|
||||
$dom->createElement('Nom')
|
||||
)->appendChild($dom->createCDATASection("$CustomerInfo->lastname"));
|
||||
$order->appendChild(
|
||||
$dom->createElement('Prenom')
|
||||
)->appendChild($dom->createCDATASection("$CustomerInfo->firstname"));
|
||||
$order->appendChild(
|
||||
$dom->createElement('Adresse')
|
||||
)->appendChild($dom->createCDATASection("$CustomerInfo->address"));
|
||||
$order->appendChild(
|
||||
$dom->createElement('Adresse_Complementaire')
|
||||
)->appendChild($dom->createCDATASection("$CustomerInfo->address2"));
|
||||
$order->appendChild(
|
||||
$dom->createElement('CP')
|
||||
)->appendChild($dom->createCDATASection("$CustomerInfo->postcode"));
|
||||
$order->appendChild(
|
||||
$dom->createElement('Ville')
|
||||
)->appendChild($dom->createCDATASection("$CustomerInfo->city"));
|
||||
$order->appendChild(
|
||||
$dom->createElement('Telephone')
|
||||
)->appendChild($dom->createCDATASection("$CustomerInfo->phone"));
|
||||
|
||||
$orderLine = $order->appendChild($dom->createElement('Ligne_de_Commande'));
|
||||
|
||||
$key = array_search('qty', array_column($fields->orderLine, 'fieldName'));
|
||||
if ($key === false)
|
||||
if ($key === false) {
|
||||
$orderLine->appendChild($dom->createElement('Quantite', '1'));
|
||||
}
|
||||
|
||||
$key = array_search('package_unit_weight', array_column($fields->orderLine, 'fieldName'));
|
||||
if ($key === false)
|
||||
if ($key === false) {
|
||||
$orderLine->appendChild($dom->createElement('Poids_Unitaire_Colis'));
|
||||
}
|
||||
|
||||
foreach ($fields->orderLine as $value){
|
||||
if (isset($pivot[$value->fieldName]) && $value->fieldName !== 'code_on_pack' && $value->fieldName !== 'code_unique')
|
||||
foreach ($fields->orderLine as $value) {
|
||||
// phpcs:ignore PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace
|
||||
if (
|
||||
isset($pivot[$value->fieldName]) &&
|
||||
$value->fieldName !== 'code_on_pack' &&
|
||||
$value->fieldName !== 'code_unique'
|
||||
) {
|
||||
$orderLine->appendChild($dom->createElement($pivot[$value->fieldName], $value->fieldValue));
|
||||
}
|
||||
}
|
||||
|
||||
if ($type === 'game') {
|
||||
$key = array_search('code_on_pack', array_column($fields->orderLine, 'fieldName'));
|
||||
if ($key)
|
||||
$orderLine->appendChild($dom->createElement('Code_on_Pack'))->appendChild($dom->createCDATASection($fields->orderLine[$key]->fieldValue));
|
||||
if ($key) {
|
||||
$orderLine->appendChild(
|
||||
$dom->createElement('Code_on_Pack')
|
||||
)->appendChild($dom->createCDATASection($fields->orderLine[$key]->fieldValue));
|
||||
}
|
||||
|
||||
$key = array_search('code_unique', array_column($fields->orderLine, 'fieldName'));
|
||||
if ($key)
|
||||
$orderLine->appendChild($dom->createElement('Code_Unique'))->appendChild($dom->createCDATASection($fields->orderLine[$key]->fieldValue));
|
||||
if ($key) {
|
||||
$orderLine->appendChild(
|
||||
$dom->createElement('Code_Unique')
|
||||
)->appendChild($dom->createCDATASection($fields->orderLine[$key]->fieldValue));
|
||||
}
|
||||
}
|
||||
|
||||
return $dom->saveXML();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use App\Http\Controllers\Controller;
|
|||
use App\Http\Resources\CustomerResource;
|
||||
use App\Http\Resources\StatusResource;
|
||||
use App\Models\Customer;
|
||||
use App\Models\CustomerInfos;
|
||||
use App\Models\CustomerInfo;
|
||||
use App\Models\CustomerLogin;
|
||||
use App\Models\CustomerOptInHistory;
|
||||
use App\Models\SingleOptin;
|
||||
|
|
@ -35,8 +35,12 @@ class CustomerController extends Controller
|
|||
'birth_date' => 'date_format:Y-m-d'
|
||||
]);
|
||||
|
||||
if ($validator->fails())
|
||||
return new StatusResource(['status' => 'KO', 'code' => 102, 'message' => 'Error on required fields.', 'errors' => $validator->errors()]);
|
||||
if ($validator->fails()) {
|
||||
return new StatusResource([
|
||||
'status' => 'KO', 'code' => 102,
|
||||
'message' => 'Error on required fields.', 'errors' => $validator->errors()
|
||||
]);
|
||||
}
|
||||
|
||||
$brandId = $request->brand_id;
|
||||
$email = filter_var($request->email, FILTER_SANITIZE_EMAIL);
|
||||
|
|
@ -54,31 +58,43 @@ class CustomerController extends Controller
|
|||
$customer->email = $email;
|
||||
$customer->save();
|
||||
$singleOptin = SingleOptin::where([['email', $email], ['brand_id', $brandId]])->first();
|
||||
if ($singleOptin)
|
||||
if ($singleOptin) {
|
||||
$singleOptin->delete();
|
||||
}
|
||||
} else {
|
||||
// Récupère les infos s'ils existent déjà
|
||||
$customerInfos = CustomerInfos::where([['customer_id', $customer->id], ['brand_id', $brandId]])->first();
|
||||
if ($customerInfos)
|
||||
return new StatusResource(['status' => 'KO', 'code' => 103, 'message' => 'User already registered on this site.']);
|
||||
$CustomerInfo = CustomerInfo::where([['customer_id', $customer->id], ['brand_id', $brandId]])->first();
|
||||
if ($CustomerInfo) {
|
||||
return new StatusResource([
|
||||
'status' => 'KO', 'code' => 103,
|
||||
'message' => 'User already registered on this site.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$customerInfos = new CustomerInfos();
|
||||
$customerInfos->firstname = $firstname;
|
||||
$customerInfos->lastname = $lastname;
|
||||
$customerInfos->birth_date = !empty($request->birth_date) ? filter_var($request->birth_date, FILTER_SANITIZE_STRING) : null;
|
||||
$customerInfos->address = !empty($request->address) ? filter_var($request->address, FILTER_SANITIZE_STRING) : null;
|
||||
$customerInfos->address2 = !empty($request->address2) ? filter_var($request->address2, FILTER_SANITIZE_STRING) : null;
|
||||
$customerInfos->phone = !empty($request->phone) ? filter_var($request->phone, FILTER_SANITIZE_STRING) : null;
|
||||
$customerInfos->country = !empty($request->country) ? filter_var($request->country, FILTER_SANITIZE_STRING) : null;
|
||||
$customerInfos->city = !empty($request->city) ? filter_var($request->city, FILTER_SANITIZE_STRING) : null;
|
||||
$customerInfos->postcode = !empty($request->postcode) ? filter_var($request->postcode, FILTER_SANITIZE_STRING) : null;
|
||||
$customerInfos->opt_in = $optIn;
|
||||
$customerInfos->hashcode = $hashcode;
|
||||
$customerInfos->brand_id = $brandId;
|
||||
$customerInfos->customer_id = $customer->id;
|
||||
$CustomerInfo = new CustomerInfo();
|
||||
$CustomerInfo->firstname = $firstname;
|
||||
$CustomerInfo->lastname = $lastname;
|
||||
$CustomerInfo->birth_date = !empty($request->birth_date) ?
|
||||
filter_var($request->birth_date, FILTER_SANITIZE_STRING) : null;
|
||||
$CustomerInfo->address = !empty($request->address) ?
|
||||
filter_var($request->address, FILTER_SANITIZE_STRING) : null;
|
||||
$CustomerInfo->address2 = !empty($request->address2) ?
|
||||
filter_var($request->address2, FILTER_SANITIZE_STRING) : null;
|
||||
$CustomerInfo->phone = !empty($request->phone) ?
|
||||
filter_var($request->phone, FILTER_SANITIZE_STRING) : null;
|
||||
$CustomerInfo->country = !empty($request->country) ?
|
||||
filter_var($request->country, FILTER_SANITIZE_STRING) : null;
|
||||
$CustomerInfo->city = !empty($request->city) ?
|
||||
filter_var($request->city, FILTER_SANITIZE_STRING) : null;
|
||||
$CustomerInfo->postcode = !empty($request->postcode) ?
|
||||
filter_var($request->postcode, FILTER_SANITIZE_STRING) : null;
|
||||
$CustomerInfo->opt_in = $optIn;
|
||||
$CustomerInfo->hashcode = $hashcode;
|
||||
$CustomerInfo->brand_id = $brandId;
|
||||
$CustomerInfo->customer_id = $customer->id;
|
||||
|
||||
$customer->infos()->save($customerInfos);
|
||||
$customer->infos()->save($CustomerInfo);
|
||||
|
||||
// Création du login pour cet utilisateur sur ce service
|
||||
$customerLogin = new CustomerLogin();
|
||||
|
|
@ -112,20 +128,23 @@ class CustomerController extends Controller
|
|||
{
|
||||
$brandId = $request->brand_id;
|
||||
|
||||
if ($type === 'id'){
|
||||
if ($type === 'id') {
|
||||
$customer = Customer::find($value);
|
||||
if (!$customer)
|
||||
if (!$customer) {
|
||||
return new StatusResource(['status' => 'KO', 'code' => 101, 'message' => 'User not found.']);
|
||||
}else if($type === 'email'){
|
||||
}
|
||||
} elseif ($type === 'email') {
|
||||
$customer = Customer::where('email', $value)->first();
|
||||
if (!$customer)
|
||||
if (!$customer) {
|
||||
return new StatusResource(['status' => 'KO', 'code' => 101, 'message' => 'User not found.']);
|
||||
}
|
||||
|
||||
$customerInfos = $customer->infos()->where('brand_id', $brandId)->first();
|
||||
$CustomerInfo = $customer->infos()->where('brand_id', $brandId)->first();
|
||||
|
||||
if (!$customerInfos)
|
||||
if (!$CustomerInfo) {
|
||||
return new StatusResource(['status' => 'KO', 'code' => 101, 'message' => 'User not found.']);
|
||||
}else{
|
||||
}
|
||||
} else {
|
||||
return new StatusResource(['status' => 'KO', 'code' => 101, 'message' => 'User not found.']);
|
||||
}
|
||||
|
||||
|
|
@ -145,50 +164,65 @@ class CustomerController extends Controller
|
|||
'birth_date' => 'date_format:Y-m-d'
|
||||
]);
|
||||
|
||||
if ($validator->fails())
|
||||
return new StatusResource(['status' => 'KO', 'code' => 104, 'message' => 'Error on required fields.', 'errors' => $validator->errors()]);
|
||||
if ($validator->fails()) {
|
||||
return new StatusResource([
|
||||
'status' => 'KO', 'code' => 104,
|
||||
'message' => 'Error on required fields.', 'errors' => $validator->errors()
|
||||
]);
|
||||
}
|
||||
|
||||
$brandId = $request->brand_id;
|
||||
$customer = Customer::find($id);
|
||||
|
||||
if (!$customer)
|
||||
if (!$customer) {
|
||||
return new StatusResource(['status' => 'KO', 'code' => 105, 'message' => 'User not found.']);
|
||||
}
|
||||
|
||||
$customerInfos = $customer->infos()->where('brand_id', $brandId)->first();
|
||||
if (!$customerInfos)
|
||||
$CustomerInfo = $customer->infos()->where('brand_id', $brandId)->first();
|
||||
if (!$CustomerInfo) {
|
||||
return new StatusResource(['status' => 'KO', 'code' => 105, 'message' => 'User not found.']);
|
||||
}
|
||||
|
||||
if (isset($request->firstname))
|
||||
$customerInfos->firstname = filter_var($request->firstname, FILTER_SANITIZE_STRING);
|
||||
if (isset($request->firstname)) {
|
||||
$CustomerInfo->firstname = filter_var($request->firstname, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
if (isset($request->lastname))
|
||||
$customerInfos->lastname = filter_var($request->lastname, FILTER_SANITIZE_STRING);
|
||||
if (isset($request->lastname)) {
|
||||
$CustomerInfo->lastname = filter_var($request->lastname, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
if (isset($request->birth_date))
|
||||
$customerInfos->birth_date = filter_var($request->birth_date, FILTER_SANITIZE_STRING);
|
||||
if (isset($request->birth_date)) {
|
||||
$CustomerInfo->birth_date = filter_var($request->birth_date, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
if (isset($request->address))
|
||||
$customerInfos->address = filter_var($request->address, FILTER_SANITIZE_STRING);
|
||||
if (isset($request->address)) {
|
||||
$CustomerInfo->address = filter_var($request->address, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
if (isset($request->address2))
|
||||
$customerInfos->address2 = filter_var($request->address2, FILTER_SANITIZE_STRING);
|
||||
if (isset($request->address2)) {
|
||||
$CustomerInfo->address2 = filter_var($request->address2, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
if (isset($request->phone))
|
||||
$customerInfos->phone = filter_var($request->phone, FILTER_SANITIZE_STRING);
|
||||
if (isset($request->phone)) {
|
||||
$CustomerInfo->phone = filter_var($request->phone, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
if (isset($request->country))
|
||||
$customerInfos->country = filter_var($request->country, FILTER_SANITIZE_STRING);
|
||||
if (isset($request->country)) {
|
||||
$CustomerInfo->country = filter_var($request->country, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
if (isset($request->city))
|
||||
$customerInfos->city = filter_var($request->city, FILTER_SANITIZE_STRING);
|
||||
if (isset($request->city)) {
|
||||
$CustomerInfo->city = filter_var($request->city, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
if (isset($request->postcode))
|
||||
$customerInfos->postcode = filter_var($request->postcode, FILTER_SANITIZE_STRING);
|
||||
if (isset($request->postcode)) {
|
||||
$CustomerInfo->postcode = filter_var($request->postcode, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
if (isset($request->opt_in)) {
|
||||
$optIn = filter_var($request->opt_in, FILTER_SANITIZE_STRING);
|
||||
|
||||
if ($customerInfos->opt_in != $optIn) {
|
||||
if ($CustomerInfo->opt_in != $optIn) {
|
||||
// Ajout dans la table d'historique des opt-in de la nouvelle valeur
|
||||
$optInHistory = new CustomerOptInHistory();
|
||||
$optInHistory->customer_id = $customer->id;
|
||||
|
|
@ -197,10 +231,10 @@ class CustomerController extends Controller
|
|||
$optInHistory->save();
|
||||
}
|
||||
|
||||
$customerInfos->opt_in = $optIn;
|
||||
$CustomerInfo->opt_in = $optIn;
|
||||
}
|
||||
|
||||
$customerInfos->save();
|
||||
$CustomerInfo->save();
|
||||
|
||||
return new CustomerResource($customer, $brandId);
|
||||
}
|
||||
|
|
@ -210,14 +244,19 @@ class CustomerController extends Controller
|
|||
* @param Request $request
|
||||
* @return CustomerResource|StatusResource
|
||||
*/
|
||||
public function authenticate(Request $request) {
|
||||
public function authenticate(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'email' => 'required|email',
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails())
|
||||
return new StatusResource(['status' => 'KO', 'code' => 115, 'message' => 'Error on required fields.', 'errors' => $validator->errors()]);
|
||||
if ($validator->fails()) {
|
||||
return new StatusResource([
|
||||
'status' => 'KO', 'code' => 115,
|
||||
'message' => 'Error on required fields.', 'errors' => $validator->errors()
|
||||
]);
|
||||
}
|
||||
|
||||
$brandId = $request->brand_id;
|
||||
$email = filter_var($request->email, FILTER_SANITIZE_EMAIL);
|
||||
|
|
@ -250,7 +289,8 @@ class CustomerController extends Controller
|
|||
'hashcode' => $infos->hashcode,
|
||||
'status' => $login->status,
|
||||
]
|
||||
]);
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$login->last_connection = now();
|
||||
|
|
@ -274,13 +314,18 @@ class CustomerController extends Controller
|
|||
* @param Request $request
|
||||
* @param $id
|
||||
*/
|
||||
public function changePassword(Request $request, $id) {
|
||||
public function changePassword(Request $request, $id)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails())
|
||||
return new StatusResource(['status' => 'KO', 'code' => 107, 'message' => 'Error on required fields.', 'errors' => $validator->errors()]);
|
||||
if ($validator->fails()) {
|
||||
return new StatusResource([
|
||||
'status' => 'KO', 'code' => 107,
|
||||
'message' => 'Error on required fields.', 'errors' => $validator->errors()
|
||||
]);
|
||||
}
|
||||
|
||||
$brandId = $request->brand_id;
|
||||
$customer = Customer::find($id);
|
||||
|
|
@ -307,7 +352,10 @@ class CustomerController extends Controller
|
|||
* @param Request $request
|
||||
* @param $id
|
||||
*/
|
||||
public function activateAccount(Request $request, $id) {
|
||||
public function activateAccount(
|
||||
Request $request,
|
||||
$id
|
||||
) {
|
||||
$brandId = $request->brand_id;
|
||||
|
||||
$customer = Customer::find($id);
|
||||
|
|
@ -338,7 +386,8 @@ class CustomerController extends Controller
|
|||
* @param Request $request
|
||||
* @param $id
|
||||
*/
|
||||
public function delete(Request $request, $id) {
|
||||
public function delete(Request $request, $id)
|
||||
{
|
||||
die("Not implemented yet");
|
||||
// TODO : A voir pour les stats, obuton dans le bo qui permet de faire les stats sur les customer puis supprimer
|
||||
// TODO : Gestion avec mesBR
|
||||
|
|
@ -368,7 +417,8 @@ class CustomerController extends Controller
|
|||
* @param Request $request
|
||||
* @param $id
|
||||
*/
|
||||
public function toggleOptin(Request $request, $id) {
|
||||
public function toggleOptin(Request $request, $id)
|
||||
{
|
||||
// TODO : Liaison des opt-in avec MailJet
|
||||
$brandId = $request->brand_id;
|
||||
|
||||
|
|
@ -398,28 +448,41 @@ class CustomerController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function addSingleOptin(Request $request) {
|
||||
public function addSingleOptin(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'email' => 'required|email',
|
||||
]);
|
||||
|
||||
if ($validator->fails())
|
||||
return new StatusResource(['status' => 'KO', 'code' => 120, 'message' => 'Error on required fields.', 'errors' => $validator->errors()]);
|
||||
if ($validator->fails()) {
|
||||
return new StatusResource([
|
||||
'status' => 'KO', 'code' => 120,
|
||||
'message' => 'Error on required fields.', 'errors' => $validator->errors()
|
||||
]);
|
||||
}
|
||||
|
||||
$brandId = $request->brand_id;
|
||||
$email = filter_var($request->email, FILTER_SANITIZE_EMAIL);
|
||||
|
||||
// Check si le customer ou l'optin simple existe avant de l'ajouter en optin simple
|
||||
if (!SingleOptin::where([['email', $email], ['brand_id', $brandId]])->exists() &&
|
||||
!CustomerInfos::join("customers", "customer_infos.customer_id", "=", "customers.id")->where([['brand_id', $brandId], ['email', $email]])->exists()) {
|
||||
// phpcs:ignore PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace
|
||||
if (
|
||||
!SingleOptin::where([['email', $email], ['brand_id', $brandId]])->exists() &&
|
||||
!CustomerInfo::join("customers", "customer_infos.customer_id", "=", "customers.id")->where([
|
||||
['brand_id', $brandId], ['email', $email]
|
||||
])->exists()
|
||||
) {
|
||||
$singleOptin = new SingleOptin();
|
||||
$singleOptin->email = $email;
|
||||
$singleOptin->brand_id = $brandId;
|
||||
$singleOptin->save();
|
||||
} else {
|
||||
// "Cet utilisateur est déjà inscrit à la newsletter pour cette marque"
|
||||
return new StatusResource(['status' => 'KO', 'code' => 121, 'message' => 'This user is already subscribed to the newsletter for this brand.']);
|
||||
return new StatusResource([
|
||||
'status' => 'KO', 'code' => 121,
|
||||
'message' => 'This user is already subscribed to the newsletter for this brand.'
|
||||
]);
|
||||
}
|
||||
return new StatusResource(['status' => 'OK' , 'message' => 'Optin added.']);
|
||||
return new StatusResource(['status' => 'OK', 'message' => 'Optin added.']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,16 +8,19 @@ use Illuminate\Http\Request;
|
|||
|
||||
class BrandController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$brands = Brand::all();
|
||||
return view('brands.index', compact('brands'));
|
||||
}
|
||||
|
||||
public function manage(Request $request, $id = null) {
|
||||
public function manage(Request $request, $id = null)
|
||||
{
|
||||
$brand = null;
|
||||
|
||||
if ($id !== null)
|
||||
if ($id !== null) {
|
||||
$brand = Brand::find($id);
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$request->validate([
|
||||
|
|
|
|||
|
|
@ -9,5 +9,7 @@ use Illuminate\Routing\Controller as BaseController;
|
|||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
use AuthorizesRequests;
|
||||
use DispatchesJobs;
|
||||
use ValidatesRequests;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,39 +4,67 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Models\Brand;
|
||||
use App\Models\Customer;
|
||||
use App\Models\CustomerInfos;
|
||||
use App\Models\CustomerInfo;
|
||||
use App\Models\CustomerLogin;
|
||||
|
||||
class CustomerController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$brands = Brand::select('id', 'name')->get();
|
||||
return view('customers.index', compact('brands'));
|
||||
}
|
||||
|
||||
public function show($id, $brandId) {
|
||||
$customerInfos = CustomerInfos::where([['customer_id', $id], ['brand_id', $brandId]])->first();
|
||||
public function show($id, $brandId)
|
||||
{
|
||||
$CustomerInfo = CustomerInfo::where([['customer_id', $id], ['brand_id', $brandId]])->first();
|
||||
$customerLogin = CustomerLogin::where([['customer_id', $id], ['brand_id', $brandId]])->first();
|
||||
if (!$customerInfos)
|
||||
if (!$CustomerInfo) {
|
||||
abort(404);
|
||||
return view('customers.show', compact('customerInfos', 'customerLogin'));
|
||||
}
|
||||
return view('customers.show', compact('CustomerInfo', 'customerLogin'));
|
||||
}
|
||||
|
||||
public function filter($texte, $brandId = null) {
|
||||
public function filter($texte, $brandId = null)
|
||||
{
|
||||
if ($brandId !== null) {
|
||||
$customers = Customer::join('customer_infos', 'customers.id', '=', 'customer_infos.customer_id')
|
||||
->join('customer_login', 'customers.id', '=', 'customer_login.customer_id')
|
||||
->select('customer_infos.customer_id', 'customer_infos.firstname', 'customer_infos.lastname', 'customer_infos.opt_in', 'customers.email', 'customer_infos.brand_id', 'customer_login.last_connection')
|
||||
->where([['lastname', 'like', '%' . $texte . '%'], ['customer_infos.brand_id', $brandId], ['customer_login.brand_id', $brandId]])
|
||||
->orWhere([['email', 'like', '%' . $texte . '%'], ['customer_infos.brand_id', $brandId], ['customer_login.brand_id', $brandId]])
|
||||
->select(
|
||||
'customer_infos.customer_id',
|
||||
'customer_infos.firstname',
|
||||
'customer_infos.lastname',
|
||||
'customer_infos.opt_in',
|
||||
'customers.email',
|
||||
'customer_infos.brand_id',
|
||||
'customer_login.last_connection'
|
||||
)
|
||||
->where([
|
||||
['lastname', 'like', '%' . $texte . '%'],
|
||||
['customer_infos.brand_id', $brandId],
|
||||
['customer_login.brand_id', $brandId]
|
||||
])
|
||||
->orWhere([
|
||||
['email', 'like', '%' . $texte . '%'],
|
||||
['customer_infos.brand_id', $brandId],
|
||||
['customer_login.brand_id', $brandId]
|
||||
])
|
||||
->get();
|
||||
} else {
|
||||
$customers = CustomerInfos::join('customers', 'customers.id', '=', 'customer_infos.customer_id')
|
||||
->join('customer_login', function($join) {
|
||||
$customers = CustomerInfo::join('customers', 'customers.id', '=', 'customer_infos.customer_id')
|
||||
->join('customer_login', function ($join) {
|
||||
$join->on('customer_login.customer_id', '=', 'customer_infos.customer_id');
|
||||
$join->on('customer_login.brand_id', '=', 'customer_infos.brand_id');
|
||||
})
|
||||
->select('customer_infos.customer_id', 'customer_infos.firstname', 'customer_infos.lastname', 'customer_infos.opt_in', 'customers.email', 'customer_infos.brand_id', 'customer_login.last_connection')
|
||||
->select(
|
||||
'customer_infos.customer_id',
|
||||
'customer_infos.firstname',
|
||||
'customer_infos.lastname',
|
||||
'customer_infos.opt_in',
|
||||
'customers.email',
|
||||
'customer_infos.brand_id',
|
||||
'customer_login.last_connection'
|
||||
)
|
||||
->where('lastname', 'like', '%' . $texte . '%')
|
||||
->orWhere('email', 'like', '%' . $texte . '%')
|
||||
->get();
|
||||
|
|
|
|||
|
|
@ -7,19 +7,29 @@ use Illuminate\Support\Facades\Auth;
|
|||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
|
||||
public function authenticate(Request $request) {
|
||||
if (Auth::attempt(["email" => $request->email, "password" => $request->password], $request->remember !== null ? true : false)) {
|
||||
public function authenticate(Request $request)
|
||||
{
|
||||
// phpcs:ignore PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace
|
||||
if (
|
||||
Auth::attempt(
|
||||
["email" => $request->email, "password" => $request->password],
|
||||
$request->remember !== null ? true : false
|
||||
)
|
||||
) {
|
||||
return redirect()->route('customers');
|
||||
} else {
|
||||
return back()->withInput($request->except("password"))->withErrors("Les identifiants entrés sont incorrects, veuillez réessayer.");
|
||||
return back()->withInput($request->except("password"))
|
||||
->withErrors("Les identifiants entrés sont incorrects, veuillez réessayer.");
|
||||
}
|
||||
}
|
||||
|
||||
public function logout() {
|
||||
public function logout()
|
||||
{
|
||||
Auth::logout();
|
||||
return redirect()->route('login');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,14 @@ use Illuminate\Support\Str;
|
|||
|
||||
class ServiceController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$services = Service::all();
|
||||
return view('services.index', compact('services'));
|
||||
}
|
||||
|
||||
public function manage(Request $request, $id = null) {
|
||||
public function manage(Request $request, $id = null)
|
||||
{
|
||||
$service = null;
|
||||
$brands = Brand::all();
|
||||
$edit = false;
|
||||
|
|
@ -40,17 +42,20 @@ class ServiceController extends Controller
|
|||
$service->brand_id = filter_var($request->brand_id, FILTER_SANITIZE_NUMBER_INT);
|
||||
$service->save();
|
||||
|
||||
return redirect()->route('services')->with('success', $edit ? 'Modifications enregistrées !' : 'Token du service : ' . $apiToken);
|
||||
return redirect()->route('services')
|
||||
->with('success', $edit ? 'Modifications enregistrées !' : 'Token du service : ' . $apiToken);
|
||||
}
|
||||
|
||||
return view('services.manage', compact('service', 'brands', 'edit'));
|
||||
}
|
||||
|
||||
public function generateApiToken($serviceId) {
|
||||
public function generateApiToken($serviceId)
|
||||
{
|
||||
$service = Service::find($serviceId);
|
||||
|
||||
if (!$service)
|
||||
if (!$service) {
|
||||
return back()->with('error', "Génération impossible : Service introuvable.");
|
||||
}
|
||||
|
||||
$apiToken = Str::random(80);
|
||||
$service->api_token = hash('sha256', $apiToken);
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@ use App\Models\SingleOptin;
|
|||
|
||||
class SingleOptinsController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$brands = Brand::select('id', 'name')->get();
|
||||
return view('single-optins.index', compact('brands'));
|
||||
}
|
||||
|
||||
public function filter($texte, $brandId = null) {
|
||||
public function filter($texte, $brandId = null)
|
||||
{
|
||||
if ($brandId !== null) {
|
||||
$customers = SingleOptin::where([['email', 'like', '%' . $texte . '%'], ['brand_id', $brandId]])->get();
|
||||
} else {
|
||||
|
|
@ -23,11 +25,13 @@ class SingleOptinsController extends Controller
|
|||
return response()->json($customers);
|
||||
}
|
||||
|
||||
public function delete($id) {
|
||||
public function delete($id)
|
||||
{
|
||||
// TODO : Gestion avec les stats
|
||||
$optin = SingleOptin::find($id);
|
||||
if ($optin)
|
||||
if ($optin) {
|
||||
$optin->delete();
|
||||
}
|
||||
return new StatusResource(['status' => "OK"]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,19 +22,22 @@ class CheckBrand
|
|||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if ($request->bearerToken() !== null)
|
||||
if ($request->bearerToken() !== null) {
|
||||
$this->apiToken = $request->bearerToken();
|
||||
else
|
||||
} else {
|
||||
$this->apiToken = ($request->api_token !== null ? $request->api_token : null);
|
||||
}
|
||||
|
||||
if ($this->apiToken === null)
|
||||
if ($this->apiToken === null) {
|
||||
die("Le token d'authentification est incorrect");
|
||||
}
|
||||
$brand = Brand::whereHas('services', function (Builder $query) {
|
||||
$query->where("api_token", hash('sha256', $this->apiToken));
|
||||
})->first();
|
||||
|
||||
if (!$brand)
|
||||
if (!$brand) {
|
||||
die("Le token d'authentification est incorrect");
|
||||
}
|
||||
|
||||
$serviceStat = ServiceStat::firstOrNew(['date' => date('Y-m-d')]);
|
||||
$serviceStat->brand_id = $brand->id;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ class CustomerResource extends JsonResource
|
|||
{
|
||||
private $brandId;
|
||||
|
||||
public function __construct($resource, $brandId) {
|
||||
public function __construct($resource, $brandId)
|
||||
{
|
||||
parent::__construct($resource);
|
||||
$this->brandId = $brandId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,12 @@ use Illuminate\Queue\SerializesModels;
|
|||
|
||||
class CourrierArcadiaError extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
public $subject, $msg, $xml;
|
||||
public $subject;
|
||||
public $msg;
|
||||
public $xml;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
|
|
@ -33,6 +36,8 @@ class CourrierArcadiaError extends Mailable implements ShouldQueue
|
|||
public function build()
|
||||
{
|
||||
$msg = $this->msg;
|
||||
return $this->subject("[LDC CRM] ". $this->subject)->view('mail.arcadia-error', compact('msg'))->attachData($this->xml, date ("Ymd_His") . '.xml', ['mime' => 'application/xml']);
|
||||
return $this->subject("[LDC CRM] " . $this->subject)
|
||||
->view('mail.arcadia-error', compact('msg'))
|
||||
->attachData($this->xml, date("Ymd_His") . '.xml', ['mime' => 'application/xml']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,21 +9,43 @@ class Brand extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "brands";
|
||||
|
||||
public function services() {
|
||||
return $this->hasMany('App\Models\Service', 'brand_id');
|
||||
/**
|
||||
* Service hasMany relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function services()
|
||||
{
|
||||
return $this->hasMany(Service::class);
|
||||
}
|
||||
|
||||
public function customer_infos() {
|
||||
return $this->hasMany('App\Models\CustomerInfos', 'brand_id');
|
||||
/**
|
||||
* CustomerInfo hasMany relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function customerInfos()
|
||||
{
|
||||
return $this->hasMany(CustomerInfo::class);
|
||||
}
|
||||
|
||||
public function services_stats() {
|
||||
return $this->hasMany('App\Models\ServiceStat', 'brand_id');
|
||||
/**
|
||||
* ServiceStat hasMany relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function servicesStats()
|
||||
{
|
||||
return $this->hasMany(ServiceStat::class);
|
||||
}
|
||||
|
||||
public function single_optins() {
|
||||
return $this->hasMany('App\Models\SingleOptin', 'brand_id');
|
||||
/**
|
||||
* SingleOptin hasMany relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function singleOptins()
|
||||
{
|
||||
return $this->hasMany(SingleOptin::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,17 +9,33 @@ class Customer extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "customers";
|
||||
|
||||
public function infos() {
|
||||
return $this->hasMany('App\Models\CustomerInfos', 'customer_id');
|
||||
/**
|
||||
* CustomerInfo hasMany relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function infos()
|
||||
{
|
||||
return $this->hasMany(CustomerInfo::class);
|
||||
}
|
||||
|
||||
public function logins() {
|
||||
return $this->hasMany('App\Models\CustomerLogin', 'customer_id');
|
||||
/**
|
||||
* CustomerLogin hasMany relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function logins()
|
||||
{
|
||||
return $this->hasMany(CustomerLogin::class);
|
||||
}
|
||||
|
||||
public function optInHistory() {
|
||||
return $this->hasMany('App\Models\CustomerOptInHistory', 'customer_id');
|
||||
/**
|
||||
* CustomerOptInHistory hasMany relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function optInHistory()
|
||||
{
|
||||
return $this->hasMany(CustomerOptInHistory::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
31
app/Models/CustomerInfo.php
Normal file
31
app/Models/CustomerInfo.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CustomerInfo extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Customer BelongsTo relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Brand BelongsTo relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function brand()
|
||||
{
|
||||
return $this->belongsTo(Brand::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CustomerInfos extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "customer_infos";
|
||||
|
||||
public function customer() {
|
||||
return $this->belongsTo('App\Models\Customer', 'customer_id');
|
||||
}
|
||||
|
||||
public function brand() {
|
||||
return $this->belongsTo('App\Models\Brand', 'brand_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -9,9 +9,13 @@ class CustomerLogin extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "customer_login";
|
||||
|
||||
public function customer() {
|
||||
return $this->belongsTo('App\Models\Customer', 'customer_id');
|
||||
/**
|
||||
* Customer BelongsTo relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,13 @@ class CustomerOptInHistory extends Model
|
|||
|
||||
protected $table = "customer_opt_in_history";
|
||||
|
||||
public function customer() {
|
||||
return $this->belongsTo('App\Models\Customer', 'customer_id');
|
||||
/**
|
||||
* Customer BelongsTo relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,13 +9,23 @@ class Service extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "services";
|
||||
|
||||
public function brand() {
|
||||
return $this->belongsTo('App\Models\Brand', 'brand_id');
|
||||
/**
|
||||
* Brand BelongsTo relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function brand()
|
||||
{
|
||||
return $this->belongsTo(Brand::class);
|
||||
}
|
||||
|
||||
public function services_stats() {
|
||||
return $this->hasMany('App\Models\ServiceStat', 'service_id');
|
||||
/**
|
||||
* ServiceStat hasMany relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function servicesStats()
|
||||
{
|
||||
return $this->hasMany(ServiceStat::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,13 +11,23 @@ class ServiceStat extends Model
|
|||
|
||||
protected $fillable = ['date'];
|
||||
|
||||
protected $table = "services_stats";
|
||||
|
||||
public function brand() {
|
||||
return $this->belongsTo('App\Models\Brand', 'brand_id');
|
||||
/**
|
||||
* Brand BelongsTo relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function brand()
|
||||
{
|
||||
return $this->belongsTo(Brand::class);
|
||||
}
|
||||
|
||||
public function service() {
|
||||
return $this->belongsTo('App\Models\Service', 'service_id');
|
||||
/**
|
||||
* Service BelongsTo relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,13 @@ class SingleOptin extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "single_optin";
|
||||
|
||||
public function brand() {
|
||||
return $this->belongsTo('App\Models\Brand', 'brand_id');
|
||||
/**
|
||||
* Brand BelongsTo relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function brand()
|
||||
{
|
||||
return $this->belongsTo(Brand::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use Illuminate\Notifications\Notifiable;
|
|||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasFactory, Notifiable;
|
||||
use HasFactory;
|
||||
use Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
|
|
@ -25,8 +26,8 @@ class AppServiceProvider extends ServiceProvider
|
|||
public function boot()
|
||||
{
|
||||
JsonResource::withoutWrapping();
|
||||
if(config('app.env') !== 'local') {
|
||||
\URL::forceScheme('https');
|
||||
if (config('app.env') !== 'local') {
|
||||
URL::forceScheme('https');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,27 +8,32 @@
|
|||
],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^7.3|^8.0",
|
||||
"php": "^7",
|
||||
"ext-curl": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-json": "*",
|
||||
"doctrine/dbal": "^3.0",
|
||||
"fideloper/proxy": "^4.4",
|
||||
"fruitcake/laravel-cors": "^2.0",
|
||||
"guzzlehttp/guzzle": "^7.0.1",
|
||||
"laravel/framework": "^8.12",
|
||||
"laravel/tinker": "^2.5",
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-dom": "*"
|
||||
"laravel/tinker": "^2.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"facade/ignition": "^2.5",
|
||||
"fakerphp/faker": "^1.9.1",
|
||||
"mockery/mockery": "^1.4.2",
|
||||
"nunomaduro/collision": "^5.0",
|
||||
"phpunit/phpunit": "^9.3.3"
|
||||
"phpunit/phpunit": "^9.3.3",
|
||||
"squizlabs/php_codesniffer": "^3.5"
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
"sort-packages": true,
|
||||
"platform": {
|
||||
"php": "7.3.26"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
|
|
|
|||
7746
composer.lock
generated
Normal file
7746
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -99,6 +99,6 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache'),
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ return [
|
|||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ return [
|
|||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL').'/storage',
|
||||
'url' => env('APP_URL') . '/storage',
|
||||
'visibility' => 'public',
|
||||
],
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ return [
|
|||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
|
||||
Str::slug(env('APP_NAME', 'laravel'), '_') . '_session'
|
||||
),
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
class CreateUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
class CreateFailedJobsTable extends Migration
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
class CreateCustomers extends Migration
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
class CreateBrands extends Migration
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
class CreateCustomerInfos extends Migration
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
class CreateCustomerLogin extends Migration
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
class CreateSingleOptin extends Migration
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
class CreateCustomerOptInHistory extends Migration
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
class CreateServices extends Migration
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
class CreateServicesStats extends Migration
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
class RenameServicesStatsTableToServiceStats extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::rename('services_stats', 'service_stats');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::rename('service_stats', 'services_stats');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
class RenameSingleOptinToSingleOptins extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::rename('single_optin', 'single_optins');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::rename('single_optins', 'single_optin');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
class RenameCustomerLoginToOptinToCustomerLogins extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::rename('customer_login', 'customer_logins');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::rename('customer_logins', 'customer_login');
|
||||
}
|
||||
}
|
||||
13
phpcs.xml
Normal file
13
phpcs.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ruleset name="RealWorld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
|
||||
<arg name="colors"/>
|
||||
<arg name="extensions" value="php"/>
|
||||
<file>app/</file>
|
||||
<file>config/</file>
|
||||
<file>routes/</file>
|
||||
<file>tests/</file>
|
||||
<rule ref="PSR1"/>
|
||||
<rule ref="PSR2"/>
|
||||
<rule ref="PSR12"/>
|
||||
<rule ref="PSR2"/>
|
||||
</ruleset>
|
||||
|
|
@ -15,9 +15,9 @@ use App\Http\Controllers\Api\v1\ArcadiaController;
|
|||
|
|
||||
*/
|
||||
|
||||
Route::prefix('v1')->middleware(['auth:api', 'check-brand'])->group(function() {
|
||||
Route::prefix('v1')->middleware(['auth:api', 'check-brand'])->group(function () {
|
||||
// Clients
|
||||
Route::prefix('customer')->group(function (){
|
||||
Route::prefix('customer')->group(function () {
|
||||
Route::get('/{type}/{value}', [CustomerController::class, 'show']);
|
||||
Route::post('/create', [CustomerController::class, 'store']);
|
||||
Route::put('/{id}', [CustomerController::class, 'update']);
|
||||
|
|
|
|||
|
|
@ -17,26 +17,33 @@ use Illuminate\Support\Facades\Route;
|
|||
| contains the "web" middleware group. Now create something great!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::get('/login', [LoginController::class, 'index'])->name('login');
|
||||
Route::post('/login', [LoginController::class, 'authenticate'])->name('authenticate');
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
Route::get('/', function() {
|
||||
Route::get('/', function () {
|
||||
return redirect()->route('customers');
|
||||
});
|
||||
Route::get('/logout', [LoginController::class, 'logout'])->name('logout');
|
||||
// Marques
|
||||
Route::get('/brands', [BrandController::class, 'index'])->name('brands');
|
||||
Route::match(['get', 'post'], '/brand/manage/{id?}', [BrandController::class, 'manage'])->name('manage-brand');
|
||||
Route::match(['get', 'post'], '/brand/manage/{id?}', [BrandController::class, 'manage'])
|
||||
->name('manage-brand');
|
||||
// Services
|
||||
Route::get('/services', [ServiceController::class, 'index'])->name('services');
|
||||
Route::match(['get', 'post'], '/service/manage/{id?}', [ServiceController::class, 'manage'])->name('manage-service');
|
||||
Route::get('/services/{id}/token/generate', [ServiceController::class, 'generateApiToken'])->name('generate-token-service');
|
||||
Route::match(['get', 'post'], '/service/manage/{id?}', [ServiceController::class, 'manage'])
|
||||
->name('manage-service');
|
||||
Route::get('/services/{id}/token/generate', [ServiceController::class, 'generateApiToken'])
|
||||
->name('generate-token-service');
|
||||
// Clients (Customer)
|
||||
Route::get('/customers', [CustomerController::class, 'index'])->name('customers');
|
||||
Route::get('/customers/filter/{texte}/{brandId?}', [CustomerController::class, 'filter'])->name('filter-customer');
|
||||
Route::get('/customers/filter/{texte}/{brandId?}', [CustomerController::class, 'filter'])
|
||||
->name('filter-customer');
|
||||
Route::get('/customer/{id}/{brandId}', [CustomerController::class, 'show'])->name('show-customer');
|
||||
// Single optins
|
||||
Route::get('/single-optins', [SingleOptinsController::class, 'index'])->name('single-optins');
|
||||
Route::get('/single-optins/filter/{texte}/{brandId?}', [SingleOptinsController::class, 'filter'])->name('filter-single-optins');
|
||||
Route::post('/single-optins/{id}/delete', [SingleOptinsController::class, 'delete'])->name('single-optins-delete');
|
||||
Route::get('/single-optins/filter/{texte}/{brandId?}', [SingleOptinsController::class, 'filter'])
|
||||
->name('filter-single-optins');
|
||||
Route::post('/single-optins/{id}/delete', [SingleOptinsController::class, 'delete'])
|
||||
->name('single-optins-delete');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ trait CreatesApplication
|
|||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
$app = require __DIR__ . '/../bootstrap/app.php';
|
||||
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue