feat: sparkles: form back and front + newsletter subscribe and unsubscribe + alert message #58
feat: sparkles: form back and front + newsletter subscribe and unsubscribe + alert message
This commit is contained in:
parent
b9a0ff8b04
commit
c439c6c089
36 changed files with 3938 additions and 2857 deletions
|
|
@ -221,4 +221,44 @@ enum ContactFormType: int
|
|||
default => [],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the slug for each type
|
||||
*
|
||||
* @return null|string[]
|
||||
*/
|
||||
public function getContactMails()
|
||||
{
|
||||
return match ($this) {
|
||||
self::collaborator => [],
|
||||
self::breeder => [
|
||||
'marie-charlotte.garnier@ldc.fr',
|
||||
'dylan.chevalier@ldc.fr'
|
||||
],
|
||||
self::professional => null,
|
||||
self::restauration => [
|
||||
'rhd@ldc.fr'
|
||||
],
|
||||
self::export => [
|
||||
'alexis.lambert@ldc.fr',
|
||||
'bruno.lafon@ldc.fr'
|
||||
],
|
||||
self::finance => [
|
||||
'david.eluaud@ldc.fr',
|
||||
'malaury.offe@ldc.fr'
|
||||
],
|
||||
self::commitments => [
|
||||
'claire-marie.gesland@ldc.fr'
|
||||
],
|
||||
self::product => [],
|
||||
self::info => [
|
||||
'blandine.durand-gratian@ldc.fr',
|
||||
'malaury.offe@ldc.fr'
|
||||
],
|
||||
self::press => [
|
||||
'communicationgroupe@ldc.fr'
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
9
app/Exceptions/AbortContactMailer.php
Normal file
9
app/Exceptions/AbortContactMailer.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class AbortContactMailer extends Exception
|
||||
{
|
||||
}
|
||||
|
|
@ -3,7 +3,15 @@
|
|||
namespace App\Http\Controllers\Front;
|
||||
|
||||
use App\Enums\Contact\ContactFormType;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Exceptions\AbortContactMailer;
|
||||
use App\Http\Requests\Front\Contact\ContactRequest;
|
||||
use App\Models\MailContactData;
|
||||
use App\Jobs\Mails\SendContactMail;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use LDC\LDCCRM\Enums\ApiError;
|
||||
use LDC\LDCCRM\Exceptions\ApiErrorException;
|
||||
use LDC\LDCCRM\Exceptions\CrmException;
|
||||
use LDC\LDCCRM\Models\SingleOptin;
|
||||
|
||||
class ContactController
|
||||
{
|
||||
|
|
@ -25,4 +33,46 @@ class ContactController
|
|||
|
||||
return view('front.pages.contact.show', compact('enumType'));
|
||||
}
|
||||
|
||||
public function send(ContactRequest $request)
|
||||
{
|
||||
$data = $request->validated();
|
||||
$messageContact = new MailContactData($data);
|
||||
$contactMessage = "";
|
||||
$hasContactError = false;
|
||||
$newsletterMessage = null;
|
||||
$hasNewsletterError = false;
|
||||
try {
|
||||
dispatch(new SendContactMail($messageContact))
|
||||
->onConnection('database')
|
||||
->onQueue('database');
|
||||
} catch (AbortContactMailer $e) {
|
||||
Log::error('Fail to build mail from contact page', [
|
||||
'exception' => $e
|
||||
]);
|
||||
$hasContactError = true;
|
||||
$contactMessage = trans('Une erreur est survenue lors de l\'envoi du message de contact.');
|
||||
}
|
||||
if (!empty($data['newsletter']) && $data['newsletter']) {
|
||||
try {
|
||||
SingleOptin::setStatus($request->email, true);
|
||||
$newsletterMessage = trans("Votre inscription à la newsletter a été prise en compte");
|
||||
} catch (ApiErrorException $e) {
|
||||
if ($e->getApiError()->equals(ApiError::singleOptinCustomerExists)) {
|
||||
$newsletterMessage = trans("Vous êtes déjà inscrit avec cette adresse email");
|
||||
}
|
||||
report($e);
|
||||
$hasNewsletterError = true;
|
||||
$newsletterMessage = trans('Une erreur est survenue lors de l\'inscription à la newsletter, merci de réessayer ultérieurement.');
|
||||
} catch (CrmException $e) {
|
||||
report($e);
|
||||
$hasNewsletterError = true;
|
||||
$newsletterMessage = trans('Une erreur est survenue lors de l\'inscription à la newsletter, merci de réessayer ultérieurement.');
|
||||
}
|
||||
}
|
||||
$contactMessage = trans('Votre message a bien été envoyé.');
|
||||
$message = $newsletterMessage ? $contactMessage. ' <br /> ' . $newsletterMessage : $contactMessage;
|
||||
return redirect()->back()
|
||||
->with($hasContactError || $hasNewsletterError ? 'info' : 'success', new \Illuminate\Support\HtmlString($message));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,14 @@
|
|||
|
||||
namespace App\Http\Controllers\Front;
|
||||
|
||||
use App\Http\Requests\Front\UnsubscribeNewsletterRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use LDC\LDCCRM\Enums\ApiError;
|
||||
use LDC\LDCCRM\Exceptions\ApiErrorException;
|
||||
use LDC\LDCCRM\Exceptions\CrmException;
|
||||
use LDC\LDCCRM\Exceptions\ValidationException;
|
||||
use LDC\LDCCRM\Models\Customer;
|
||||
use LDC\LDCCRM\Models\SingleOptin;
|
||||
use Uwil\LaravelCommon\Controllers\Controller;
|
||||
|
||||
class HomeController extends Controller
|
||||
|
|
@ -15,4 +23,55 @@ class HomeController extends Controller
|
|||
{
|
||||
return view('front.pages.home');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* unsubscribeNewsletter method
|
||||
*
|
||||
* @param \App\Http\Requests\Fo\UnsubscribeNewsletterRequest $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function unsubscribeNewsletter(UnsubscribeNewsletterRequest $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$error = null;
|
||||
$hashcode = $request->hashcode;
|
||||
|
||||
try {
|
||||
SingleOptin::unsetStatusWithHashcode($hashcode);
|
||||
} catch (ApiErrorException $e) {
|
||||
Log::debug($e->getMessage());
|
||||
if ($e->getApiError()->equals(ApiError::modelNotFound)) {
|
||||
if ($customer = Customer::find($hashcode)) {
|
||||
$customer->opt_in = false;
|
||||
// ! Les données peuvent être parsés en retour de la crm et inconsitantes (Héritage vielle crm).
|
||||
try {
|
||||
$customer->save();
|
||||
} catch (ValidationException $e) {
|
||||
$error = null;
|
||||
}
|
||||
} else {
|
||||
abort(404);
|
||||
}
|
||||
} else {
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
$error = true;
|
||||
}
|
||||
} catch (CrmException $e) {
|
||||
Log::debug($e->getMessage());
|
||||
$error = true;
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
} //end try
|
||||
|
||||
if (!is_null($error)) {
|
||||
return view('front.pages.newsletter-unsubscribe')->with(
|
||||
'error',
|
||||
trans('Une erreur est survenue, merci de réessayer ultérieurement')
|
||||
);
|
||||
}
|
||||
return view('front.pages.newsletter-unsubscribe');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
122
app/Http/Requests/Front/Contact/ContactRequest.php
Normal file
122
app/Http/Requests/Front/Contact/ContactRequest.php
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Front\Contact;
|
||||
|
||||
use App\Enums\Contact\BreedType;
|
||||
use App\Enums\Contact\ContactFormType;
|
||||
use App\Enums\Contact\CustomerAskingType;
|
||||
use App\Enums\Contact\PressType;
|
||||
use App\Enums\Department;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Uwil\LaravelCommon\Helpers\ToolboxHelper;
|
||||
|
||||
class ContactRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
// ToolboxHelper::validateRecaptcha($this, \config('services.google.recaptcha.version'));
|
||||
$typeContactForm = $this->input('enumType');
|
||||
|
||||
/** Validation for common fields */
|
||||
$rules = [
|
||||
'enumType' => ['required', Rule::enum(ContactFormType::class)],
|
||||
'lastname' => ['required', 'min:1', 'max:60'],
|
||||
'firstname' => ['required', 'min:1', 'max:60'],
|
||||
'message' => ['required', 'min:10', 'max:255'],
|
||||
'email' => ['required', 'min:1', 'max:60', 'email:rfc,dns,spoof'],
|
||||
];
|
||||
|
||||
/** Validation for breeder enum */
|
||||
if (ContactFormType::breeder->equals(ContactFormType::make($typeContactForm))) {
|
||||
$breeder = [
|
||||
'phone' => ['required', 'min:1', 'max:60'],
|
||||
'typeelevage' => ['array', 'min:1'],
|
||||
'typeelevage.*' => [Rule::enum(BreedType::class)],
|
||||
'zonegeo' => ['array', 'min:1'],
|
||||
'zonegeo.*' => [Rule::enum(Department::class)],
|
||||
];
|
||||
$rules = array_merge($rules, $breeder);
|
||||
}
|
||||
|
||||
/** Validation for restauration enum */
|
||||
if (ContactFormType::restauration->equals(ContactFormType::make($typeContactForm))) {
|
||||
$restauration = [
|
||||
'company' => 'string|max:255',
|
||||
];
|
||||
$rules = array_merge($rules, $restauration);
|
||||
}
|
||||
|
||||
/** Add the country field */
|
||||
if (
|
||||
ContactFormType::restauration->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::export->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::commitments->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::info->equals(ContactFormType::make($typeContactForm))
|
||||
) {
|
||||
$addCountry = [
|
||||
'country' => ['required', 'min:1', 'max:150'],
|
||||
];
|
||||
$rules = array_merge($rules, $addCountry);
|
||||
}
|
||||
|
||||
/** Add the optional phone field */
|
||||
if (
|
||||
ContactFormType::restauration->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::export->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::finance->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::commitments->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::info->equals(ContactFormType::make($typeContactForm))
|
||||
) {
|
||||
$addNoRequiredPhone = [
|
||||
'phone' => ['max:60'],
|
||||
];
|
||||
$rules = array_merge($rules, $addNoRequiredPhone);
|
||||
}
|
||||
|
||||
/** Add the town and postalcode fields */
|
||||
if (
|
||||
ContactFormType::restauration->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::export->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::finance->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::commitments->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::info->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::press->equals(ContactFormType::make($typeContactForm))
|
||||
) {
|
||||
$addTownAndPostalCodeFields = [
|
||||
'town' => 'string|required|min:2|max:255',
|
||||
'postalcode' => 'string|required|min:2|max:60',
|
||||
];
|
||||
$rules = array_merge($rules, $addTownAndPostalCodeFields);
|
||||
}
|
||||
|
||||
/** Validation for restauration and export commun fields */
|
||||
if (
|
||||
ContactFormType::restauration->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::export->equals(ContactFormType::make($typeContactForm))
|
||||
) {
|
||||
$restaurationExport = [
|
||||
'type' => ['array', 'min:1'],
|
||||
'type.*' => [Rule::enum(CustomerAskingType::class)],
|
||||
];
|
||||
$rules = array_merge($rules, $restaurationExport);
|
||||
}
|
||||
|
||||
/** Validation for press enum */
|
||||
if (ContactFormType::press->equals(ContactFormType::make($typeContactForm))) {
|
||||
$press = [
|
||||
'subject' => ['required', Rule::enum(PressType::class)],
|
||||
'company' => 'required|string|min:2|max:255',
|
||||
'phone' => ['required', 'max:60'],
|
||||
'newsletter' => 'boolean'
|
||||
];
|
||||
$rules = array_merge($rules, $press);
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Front/UnsubscribeNewsletterRequest.php
Normal file
30
app/Http/Requests/Front/UnsubscribeNewsletterRequest.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Front;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UnsubscribeNewsletterRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'hashcode' => 'required|uuid'
|
||||
];
|
||||
}
|
||||
}
|
||||
53
app/Jobs/Mails/SendContactMail.php
Normal file
53
app/Jobs/Mails/SendContactMail.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace App\Jobs\Mails;
|
||||
|
||||
use App\Enums\Contact\ContactFormType;
|
||||
use App\Mail\ContactMail;
|
||||
use App\Models\MailContactData;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendContactMail implements ShouldQueue
|
||||
{
|
||||
use Dispatchable;
|
||||
use InteractsWithQueue;
|
||||
use Queueable;
|
||||
|
||||
/** @var array List of recipients mails */
|
||||
private array $mailList;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param \App\Models\MailContactData $data
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(private MailContactData $data)
|
||||
{
|
||||
$this->mailList = ContactFormType::make($data->enumType)->getContactMails();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
foreach ($this->mailList as $recipient) {
|
||||
Mail::to($recipient)->send(new ContactMail($this->data));
|
||||
}
|
||||
Log::debug(
|
||||
sprintf(
|
||||
'Sent %s to %s',
|
||||
$this->data->enumType->label(),
|
||||
implode(',', $this->mailList)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
80
app/Mail/ContactMail.php
Normal file
80
app/Mail/ContactMail.php
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\MailContactData;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Mail\Mailables\Address;
|
||||
|
||||
class ContactMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* The order instance.
|
||||
*
|
||||
* @var \App\Models\MailContactData
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param \App\Models\MailContactData $data
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MailContactData $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*
|
||||
* @return \Illuminate\Mail\Mailables\Envelope
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
from: new Address(\config('mail.from.address'), \config('mail.from.name')),
|
||||
subject: sprintf(
|
||||
'%s - ' . config('app.name'),
|
||||
ucfirst($this->data->enumType->label())
|
||||
),
|
||||
replyTo: [new Address($this->data->email, sprintf('%s %s', $this->data->firstname, $this->data->lastname))]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*
|
||||
* @return \Illuminate\Mail\Mailables\Content
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'emails.contact',
|
||||
text: 'emails.contact-text',
|
||||
with: ['data' => $this->data]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
89
app/Models/MailContactData.php
Normal file
89
app/Models/MailContactData.php
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\Contact\BreedType;
|
||||
use App\Enums\Contact\ContactFormType;
|
||||
use App\Enums\Contact\CustomerAskingType;
|
||||
use App\Enums\Contact\PressType;
|
||||
use App\Enums\Department;
|
||||
use Illuminate\Database\Eloquent\Casts\AsEnumArrayObject;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* This class is used to store data in memory only, not in databases.
|
||||
*
|
||||
* @property integer $id Id.
|
||||
* @property \App\Enums\Contact\ContactFormType $enumType The type enum.
|
||||
* @property string $lastname The customer's lastname.
|
||||
* @property string $firstname The customer's firstname.
|
||||
* @property string $message The message.
|
||||
* @property string $email The customer's email.
|
||||
* @property string|null $phone The customer's phone.
|
||||
* @property \App\Enums\Contact\BreedType[] $typeelevage The customer's breeding type
|
||||
* @property \App\Enums\Department[] $zonegeo The customer's greographic zone
|
||||
* @property string $company The customer's company.
|
||||
* @property string $country The customer's country.
|
||||
* @property string $town The customer's town.
|
||||
* @property string $postalcode The customer's postalcode.
|
||||
* @property boolean $newsletter The customer's optin response.
|
||||
* @property \App\Enums\Contact\CustomerAskingType[] $type The customer's type asking
|
||||
* @property \App\Enums\Contact\PressType $subject The message's subject
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*/
|
||||
class MailContactData extends Model
|
||||
{
|
||||
/**
|
||||
* The database connection that should be used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $connection = null;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string, array[]>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'enumType',
|
||||
'lastname',
|
||||
'firstname',
|
||||
'message',
|
||||
'email',
|
||||
'phone',
|
||||
'typeelevage',
|
||||
'zonegeo',
|
||||
'company',
|
||||
'country',
|
||||
'town',
|
||||
'postalcode',
|
||||
'type',
|
||||
'subject',
|
||||
'newsletter'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'enumType' => ContactFormType::class,
|
||||
'typeelevage' => AsEnumArrayObject::class.':'.BreedType::class,
|
||||
'zonegeo' => AsEnumArrayObject::class.':'.Department::class,
|
||||
'type' => AsEnumArrayObject::class.':'.CustomerAskingType::class,
|
||||
'subject' => PressType::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Construct method.
|
||||
*
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function __construct(array $attributes = [])
|
||||
{
|
||||
parent::__construct($attributes);
|
||||
}
|
||||
}
|
||||
26
app/Providers/CrmApiServiceProvider.php
Normal file
26
app/Providers/CrmApiServiceProvider.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use LDC\LDCCRM\CrmApiV4;
|
||||
|
||||
class CrmApiServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
App::singleton('crmAPI', function () {
|
||||
return new CrmApiV4(
|
||||
config('crm.endpoint'),
|
||||
config('crm.token'),
|
||||
config('crm.password')
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -3,5 +3,6 @@
|
|||
return [
|
||||
Uwil\LaravelBackend\Providers\AppServiceProvider::class,
|
||||
Uwil\LaravelBackend\Providers\EventServiceProvider::class,
|
||||
Uwil\LaravelBackend\Providers\TranslationServiceProvider::class
|
||||
Uwil\LaravelBackend\Providers\TranslationServiceProvider::class,
|
||||
\App\Providers\CrmApiServiceProvider::class,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
"laravel/framework": "^12.0",
|
||||
"laravel/telescope": "^5.7",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"ldc/ldccrmv4client": "^4.1",
|
||||
"tightenco/ziggy": "^2.5",
|
||||
"uwil/laravel-activity-logs": "^3.0",
|
||||
"uwil/laravel-backend": "^3.0",
|
||||
|
|
|
|||
181
composer.lock
generated
181
composer.lock
generated
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "31ff81064d7a76d46cf837440e2e5a53",
|
||||
"content-hash": "e129d8fb9cb2107c22ca023fb1032525",
|
||||
"packages": [
|
||||
{
|
||||
"name": "24slides/laravel-saml2",
|
||||
|
|
@ -2118,6 +2118,63 @@
|
|||
},
|
||||
"time": "2025-01-27T14:24:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ldc/ldccrmv4client",
|
||||
"version": "4.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git@lab.s-web.fr:ldc-web/projets/crm-client.git",
|
||||
"reference": "153deac785992da3d4dff3dba6528d744f87289d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://lab.s-web.fr/api/v4/projects/26/packages/composer/archives/ldc/ldccrmv4client.zip?sha=153deac785992da3d4dff3dba6528d744f87289d",
|
||||
"reference": "153deac785992da3d4dff3dba6528d744f87289d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/inflector": "^2.0",
|
||||
"ext-curl": "*",
|
||||
"guzzlehttp/guzzle": "^7.4",
|
||||
"php": "^8.2",
|
||||
"respect/validation": "^2.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"orchestra/testbench": "^8.10",
|
||||
"phpunit/phpunit": "9.6",
|
||||
"slevomat/coding-standard": "^8.10",
|
||||
"squizlabs/php_codesniffer": "^3.5"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"LDC\\LDCCRM\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"LDC\\LDCCRM\\Tests\\": "tests"
|
||||
}
|
||||
},
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jérémy Munsch",
|
||||
"email": "jeremy.munsch@ldc.fr",
|
||||
"homepage": "https://jeremydev.ovh"
|
||||
}
|
||||
],
|
||||
"description": "LDC CRM Client V4",
|
||||
"homepage": "https://github.com/kwaadpepper",
|
||||
"keywords": [
|
||||
"CRM",
|
||||
"Client",
|
||||
"LDC",
|
||||
"Laravel"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "league/commonmark",
|
||||
"version": "2.7.1",
|
||||
|
|
@ -4153,6 +4210,128 @@
|
|||
},
|
||||
"time": "2025-06-25T14:20:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "respect/stringifier",
|
||||
"version": "0.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Respect/Stringifier.git",
|
||||
"reference": "e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Respect/Stringifier/zipball/e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59",
|
||||
"reference": "e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^2.8",
|
||||
"malukenho/docheader": "^0.1.7",
|
||||
"phpunit/phpunit": "^6.4"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/stringify.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Respect\\Stringifier\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Respect/Stringifier Contributors",
|
||||
"homepage": "https://github.com/Respect/Stringifier/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Converts any value to a string",
|
||||
"homepage": "http://respect.github.io/Stringifier/",
|
||||
"keywords": [
|
||||
"respect",
|
||||
"stringifier",
|
||||
"stringify"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Respect/Stringifier/issues",
|
||||
"source": "https://github.com/Respect/Stringifier/tree/0.2.0"
|
||||
},
|
||||
"time": "2017-12-29T19:39:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "respect/validation",
|
||||
"version": "2.4.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Respect/Validation.git",
|
||||
"reference": "f13f10f19978aea33af2a102a2f58f2db1e63619"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Respect/Validation/zipball/f13f10f19978aea33af2a102a2f58f2db1e63619",
|
||||
"reference": "f13f10f19978aea33af2a102a2f58f2db1e63619",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1",
|
||||
"respect/stringifier": "^0.2.0",
|
||||
"symfony/polyfill-mbstring": "^1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"egulias/email-validator": "^3.0",
|
||||
"giggsey/libphonenumber-for-php-lite": "^8.13 || ^9.0",
|
||||
"malukenho/docheader": "^1.0",
|
||||
"mikey179/vfsstream": "^1.6",
|
||||
"phpstan/phpstan": "^1.9",
|
||||
"phpstan/phpstan-deprecation-rules": "^1.1",
|
||||
"phpstan/phpstan-phpunit": "^1.3",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"psr/http-message": "^1.0",
|
||||
"respect/coding-standard": "^4.0",
|
||||
"squizlabs/php_codesniffer": "^3.7"
|
||||
},
|
||||
"suggest": {
|
||||
"egulias/email-validator": "Improves the Email rule if available",
|
||||
"ext-bcmath": "Arbitrary Precision Mathematics",
|
||||
"ext-fileinfo": "File Information",
|
||||
"ext-mbstring": "Multibyte String Functions",
|
||||
"giggsey/libphonenumber-for-php-lite": "Enables the phone rule if available"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Respect\\Validation\\": "library/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Respect/Validation Contributors",
|
||||
"homepage": "https://github.com/Respect/Validation/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"description": "The most awesome validation engine ever created for PHP",
|
||||
"homepage": "http://respect.github.io/Validation/",
|
||||
"keywords": [
|
||||
"respect",
|
||||
"validation",
|
||||
"validator"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Respect/Validation/issues",
|
||||
"source": "https://github.com/Respect/Validation/tree/2.4.4"
|
||||
},
|
||||
"time": "2025-06-07T00:07:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "robrichards/xmlseclibs",
|
||||
"version": "3.1.3",
|
||||
|
|
|
|||
7
config/crm.php
Normal file
7
config/crm.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'endpoint' => env('CRM_ENDPOINT'),
|
||||
'token' => env('CRM_TOKEN'),
|
||||
'password' => env('CRM_PASSWORD')
|
||||
];
|
||||
File diff suppressed because it is too large
Load diff
79
resources/views/components/flash-message.blade.php
Normal file
79
resources/views/components/flash-message.blade.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
@if (!request()->routeIs('login'))
|
||||
@php
|
||||
$messages = collect([
|
||||
'success' => Session::get('success'),
|
||||
'error' => Session::get('error'),
|
||||
'warning' => Session::get('warning'),
|
||||
'info' => Session::get('info'),
|
||||
'status' => Session::get('status'),
|
||||
])->filter();
|
||||
@endphp
|
||||
|
||||
@if ($messages->isNotEmpty())
|
||||
<div>
|
||||
@foreach ($messages as $type => $message)
|
||||
<div @class([
|
||||
'alert-container alert flex justify-between items-start ',
|
||||
'alert-info' => in_array($type, ['info', 'status']),
|
||||
'alert-warning' => $type === 'warning',
|
||||
'alert-danger' => $type === 'error',
|
||||
'alert-success' => $type === 'success',
|
||||
]) role="alert">
|
||||
<div class="flex items-center gap-3">
|
||||
@if (in_array($type, ['info', 'status']))
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
|
||||
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
||||
stroke-linejoin="round" class="lucide lucide-info-icon lucide-info">
|
||||
<circle cx="12" cy="12" r="10" />
|
||||
<path d="M12 16v-4" />
|
||||
<path d="M12 8h.01" />
|
||||
</svg>
|
||||
@elseif ($type === 'error')
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="lucide lucide-x-circle" width="24"
|
||||
height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2">
|
||||
<circle cx="12" cy="12" r="10" />
|
||||
<path d="M15 9l-6 6M9 9l6 6" />
|
||||
</svg>
|
||||
@elseif ($type === 'success')
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="lucide lucide-check-circle" width="24"
|
||||
height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2">
|
||||
<circle cx="12" cy="12" r="10" />
|
||||
<path d="M9 12l2 2l4 -4" />
|
||||
</svg>
|
||||
@elseif ($type === 'warning')
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="lucide lucide-alert-triangle" width="24"
|
||||
height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2">
|
||||
<path
|
||||
d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" />
|
||||
<line x1="12" y1="9" x2="12" y2="13" />
|
||||
<line x1="12" y1="17" x2="12.01" y2="17" />
|
||||
</svg>
|
||||
@endif
|
||||
<strong>{!! nl2br(e($message)) !!}</strong>
|
||||
</div>
|
||||
|
||||
<button class="alert-btn-close ml-4 shrink-0" type="button" aria-label="{{ __('Fermer') }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="lucide lucide-x" width="24" height="24"
|
||||
viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M18 6 6 18" />
|
||||
<path d="m6 6 12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
|
||||
<script nonce="{{ $nonce ?? '' }}">
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.querySelectorAll('.alert-btn-close').forEach(function(btn) {
|
||||
btn.addEventListener('click', function() {
|
||||
this.closest('.alert').classList.add('hidden');
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
@ -1,9 +1,20 @@
|
|||
<div class="form__field">
|
||||
<div class="form__field-title">{{ $label }} {{ $required ? '*' : '' }} <span class="normal">({{ __('front.multiple_choice') }})</span></div>
|
||||
@foreach($options as $option)
|
||||
<div class="form__field-title">{{ $label }} {{ isset($required) ? '*' : '' }}
|
||||
@if (isset($multiple))
|
||||
<span class="normal">
|
||||
({{ __('front.multiple_choice') }})
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
@foreach ($options as $option)
|
||||
<label class="form__field-pseudolabel">
|
||||
<input type="checkbox" name="{{ $name }}" value="{{ $option['value'] }}" @if(isset($required)) required="true" @endif>
|
||||
<input type="checkbox" name="{{ $name }}[]" value="{{ $option['value'] }}"
|
||||
@if (isset($required)) required="true" @endif>
|
||||
<span class="form__field-pseudocircle">{{ $option['label'] }}</span>
|
||||
</label>
|
||||
@endforeach
|
||||
|
||||
@error($name)
|
||||
<div class="form__error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,19 @@
|
|||
<div class="form__field">
|
||||
<div class="form__field-title">{{ $label }} {{ $required ? '*' : '' }}</div>
|
||||
<div class="geographic-checkboxes-block">
|
||||
<div class="geographic-checkboxes-result form__input"><span
|
||||
class="zones-wrapper">{{ $placeholder }}</span>
|
||||
<div class="geographic-checkboxes-result form__input"><span class="zones-wrapper">{{ $placeholder }}</span>
|
||||
</div>
|
||||
<div class="geographic-checkboxes-list">
|
||||
@foreach($options as $option)
|
||||
<label class="form__field-pseudolabel">
|
||||
<input type="checkbox" name="{{ $name }}" value="{{ $option['value'] }}" @if(isset($option['required'])) required="true" @endif>
|
||||
<span class="form__field-pseudosquare">{{ $option['label'] }}</span>
|
||||
</label>
|
||||
@foreach ($options as $option)
|
||||
<label class="form__field-pseudolabel">
|
||||
<input type="checkbox" name="{{ $name }}[]" value="{{ $option['value'] }}"
|
||||
@if (isset($option['required'])) required="true" @endif>
|
||||
<span class="form__field-pseudosquare">{{ $option['label'] }}</span>
|
||||
</label>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@error($name)
|
||||
<div class="form__error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
<div class="form__field">
|
||||
<div class="form__field-title">{{ $label }} {{ isset($required) && $required ? '*' : '' }}</div>
|
||||
<input type="{{ isset($type) ? $type : 'text' }}" name="{{ $name }}" size="{{ isset($size) ? $size : '40'}}" class="form__input"
|
||||
placeholder="{{ $placeholder }}" autocomplete="{{ isset($autoComplete) ? $autoComplete : '' }}" @if(isset($required)) required="true" @endif>
|
||||
<input type="{{ isset($type) ? $type : 'text' }}" name="{{ $name }}" size="{{ isset($size) ? $size : '40' }}"
|
||||
class="form__input" placeholder="{{ $placeholder }}"
|
||||
autocomplete="{{ isset($autoComplete) ? $autoComplete : '' }}"
|
||||
@if (isset($required)) required="true" @endif>
|
||||
@error($name)
|
||||
<div class="form__error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
<div class="form__field-title">{{ $label }} {{ $required ? '*' : '' }}</div>
|
||||
|
||||
<div class="form__field">
|
||||
<textarea name="{{ $name }}" cols="40" rows="10" class="form__input"
|
||||
placeholder="{{ $placeholder }}"
|
||||
@if(isset($required)) required="true" @endif
|
||||
></textarea>
|
||||
<textarea name="{{ $name }}" cols="40" rows="10" class="form__input" placeholder="{{ $placeholder }}"
|
||||
@if (isset($required)) required="true" @endif></textarea>
|
||||
@error($name)
|
||||
<div class="form__error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
<form id="contact-form" inert>
|
||||
<form id="contact-form" method="POST" action="{{ route('front.contact.send') }}" inert>
|
||||
@csrf
|
||||
<input type="hidden" name="enumType" value="{{ $enumType }}">
|
||||
{{ $slot }}
|
||||
</form>
|
||||
|
|
|
|||
50
resources/views/emails/contact-text.blade.php
Normal file
50
resources/views/emails/contact-text.blade.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
Formulaire : {{ $data->enumType->label() }} - LDC
|
||||
Prénom : {{ $data->firstname }}
|
||||
Nom : {{ $data->lastname }}
|
||||
Email : {{ $data->email }}
|
||||
|
||||
@if (isset($data->town))
|
||||
Ville : {{ $data->town }}
|
||||
@endif
|
||||
|
||||
@if(isset($data->postalcode))
|
||||
Code Postal : {{ $data->postalcode }}
|
||||
@endif
|
||||
|
||||
@if(isset($data->country))
|
||||
Pays : {{ $data->country }}
|
||||
@endif
|
||||
|
||||
@if (isset($data->phone))
|
||||
Téléphone : {{ $data->phone }}
|
||||
@endif
|
||||
|
||||
@if (\App\Enums\Contact\ContactFormType::breeder->equals($data->enumType))
|
||||
Type d'élevage :
|
||||
@foreach($data->typeelevage as $breeding)
|
||||
{{ $breeding->label() }}
|
||||
@endforeach
|
||||
|
||||
Zone géographique :
|
||||
@foreach($data->zonegeo as $zone)
|
||||
{{ $zone->label() }}
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
@if (\App\Enums\Contact\ContactFormType::restauration->equals($data->enumType))
|
||||
Société : {{ $data->company }}
|
||||
@endif
|
||||
|
||||
@if (\App\Enums\Contact\ContactFormType::restauration->equals($data->enumType) ||
|
||||
\App\Enums\Contact\ContactFormType::export->equals($data->enumType))
|
||||
Type de demande :
|
||||
@foreach($data->type as $t)
|
||||
{{ $t->label() }}
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
@if (\App\Enums\Contact\ContactFormType::press->equals($data->enumType))
|
||||
Sujet : {{ $data->subject->label() }}
|
||||
@endif
|
||||
|
||||
Message : {{ $data->message }}
|
||||
73
resources/views/emails/contact.blade.php
Normal file
73
resources/views/emails/contact.blade.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<head>
|
||||
<title>{{ ucfirst($data->enumType->label()) }} - LDC</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>Prénom : {{ $data->firstname }}</p>
|
||||
<p>Nom : {{ $data->lastname }}</p>
|
||||
<p>Email : {{ $data->email }}</p>
|
||||
|
||||
@if (isset($data->town))
|
||||
<p>Ville : {{ $data->town }}</p>
|
||||
@endif
|
||||
|
||||
@if(isset($data->postalcode))
|
||||
<p>Code Postal : {{ $data->postalcode }}</p>
|
||||
@endif
|
||||
|
||||
@if(isset($data->country))
|
||||
<p>Pays : {{ $data->country }}</p>
|
||||
@endif
|
||||
|
||||
@if (isset($data->phone))
|
||||
<p>Téléphone : {{ $data->phone }}</p>
|
||||
@endif
|
||||
|
||||
{{-- BREEDER --}}
|
||||
@if (\App\Enums\Contact\ContactFormType::breeder->equals($data->enumType))
|
||||
<p>Type d'élevage : </p>
|
||||
<ul>
|
||||
@foreach($data->typeelevage as $breeding)
|
||||
<li>{{ $breeding->label() }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
|
||||
<p>Zone géographique : </p>
|
||||
<ul>
|
||||
@foreach($data->zonegeo as $zone)
|
||||
<li>{{ $zone->label() }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
|
||||
{{-- Restauration, Détaillant --}}
|
||||
@if (\App\Enums\Contact\ContactFormType::restauration->equals($data->enumType))
|
||||
<p>Société : {{ $data->company }}</p>
|
||||
@endif
|
||||
|
||||
{{-- Restauration and Export --}}
|
||||
@if (\App\Enums\Contact\ContactFormType::restauration->equals($data->enumType) ||
|
||||
\App\Enums\Contact\ContactFormType::export->equals($data->enumType))
|
||||
<p>Type de demande : </p>
|
||||
<ul>
|
||||
@foreach($data->type as $t)
|
||||
<li>{{ $t->label() }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
|
||||
{{-- PRESS --}}
|
||||
@if (\App\Enums\Contact\ContactFormType::press->equals($data->enumType))
|
||||
<p>Sujet : {{ $data->subject->label() }}</p>
|
||||
@endif
|
||||
|
||||
|
||||
{{-- MESSAGE --}}
|
||||
<p>Message : {{ $data->message }}</p>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -25,7 +25,6 @@
|
|||
{{-- <?= esc_js(bcn_display_json_ld()); ?> --}}
|
||||
</script>
|
||||
|
||||
|
||||
@push('style')
|
||||
{{-- STYLE --}}
|
||||
@php
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
@include('front.layouts.mobile-menu')
|
||||
|
||||
<main>
|
||||
<x-flash-message />
|
||||
@yield('content')
|
||||
</main>
|
||||
|
||||
|
|
|
|||
|
|
@ -17,10 +17,12 @@
|
|||
placeholder="Prenom.nom@mail.fr" autoComplete="off" type="email" />
|
||||
</div>
|
||||
<div class="form__row">
|
||||
<x-front.inputs.checkbox label="{{ ucfirst(__('front.contact.inputs.breedtype.label')) }}"
|
||||
required="true" name="typeelevage" :options="collect(\App\Enums\Contact\BreedType::toArray())->map(function ($type) {
|
||||
<x-front.inputs.checkbox
|
||||
multiple="true"
|
||||
label="{{ ucfirst(__('front.contact.inputs.breedtype.label')) }}*"
|
||||
name="typeelevage" :options="collect(\App\Enums\Contact\BreedType::toArray())->map(function ($type) {
|
||||
return [
|
||||
'value' => $type->name,
|
||||
'value' => $type->value,
|
||||
'label' => $type->label,
|
||||
];
|
||||
})" />
|
||||
|
|
@ -32,7 +34,7 @@
|
|||
label="{{ ucfirst(__('front.contact.inputs.geo_zone.label')) }}" required="true"
|
||||
name="zonegeo" :options="collect(\App\Enums\Department::toArray())->map(function ($type) {
|
||||
return [
|
||||
'value' => $type->name,
|
||||
'value' => $type->value,
|
||||
'label' => $type->label,
|
||||
];
|
||||
})" />
|
||||
|
|
@ -43,5 +45,5 @@
|
|||
label="{{ ucfirst(__('front.contact.inputs.your_project.label')) }}" required="true"
|
||||
name="message"
|
||||
placeholder="{{ ucfirst(__('front.contact.inputs.your_project.placeholder')) }}"
|
||||
autoComplete="off" type="email" />
|
||||
autoComplete="off" />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
@if (\App\Enums\Contact\ContactFormType::press->equals($enumType))
|
||||
<div class="form__field">
|
||||
<label class="form__field-pseudolabel">
|
||||
<input type="checkbox" name="newsletter">
|
||||
<input type="checkbox" name="newsletter" value="1">
|
||||
<span class="form__field-pseudosquare">{{ __('front.inputs.newsletter.label') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
@endif
|
||||
<x-front.need-recaptcha-banner />
|
||||
|
||||
<x-front.pages.contact.form-wrapper>
|
||||
<x-front.pages.contact.form-wrapper :enumType="$enumType">
|
||||
@if (\App\Enums\Contact\ContactFormType::breeder->equals($enumType))
|
||||
@include('front.pages.contact.partials.breeder')
|
||||
@endif
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
<x-front.need-recaptcha-banner />
|
||||
|
||||
<x-front.pages.contact.form-wrapper>
|
||||
<x-front.pages.contact.form-wrapper :enumType="\App\Enums\Contact\ContactFormType::press">
|
||||
<div class="form__row">
|
||||
<div class="form__field form__field_flex">
|
||||
<div class="form__label">{{ __('front.contact.inputs.object.label') }} : </div>
|
||||
<span class="wpcf7-form-control-wrap">
|
||||
<select name="Subject" class="form__input form__input_notinput" aria-required="true" aria-invalid="false">
|
||||
<select name="subject" class="form__input form__input_notinput" aria-required="true" aria-invalid="false">
|
||||
<option value="" class="disabled" disabled="disabled">
|
||||
{{ __('front.contact.inputs.object.placeholder') }}
|
||||
</option>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
label="{{ ucfirst(__('front.contact.inputs.customerAskingType.label')) }}" required="true" name="type"
|
||||
:options="collect(\App\Enums\Contact\CustomerAskingType::toArray())->map(function ($type) {
|
||||
return [
|
||||
'value' => $type->name,
|
||||
'value' => $type->value,
|
||||
'label' => $type->label,
|
||||
];
|
||||
})" />
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
@include('front.breadcrumbs.breadcrumb-body')
|
||||
|
||||
|
||||
<x-front.pages.title h1Class="page-contacts__title" h2Class="contacts-page-subtitle" title="Nous contacter"
|
||||
subtitle="{{ ucfirst($enumType->subtitle()) }}" />
|
||||
|
||||
|
|
|
|||
|
|
@ -421,140 +421,6 @@
|
|||
@include('front.pages.contact.partials.press')
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* @param {number} postId
|
||||
* @param {string} action
|
||||
* @param {string} token
|
||||
* @param {Record<string,string>} data
|
||||
* @return {void}
|
||||
*/
|
||||
function ajaxContact(postId, action, token, data) {
|
||||
return $.ajax({
|
||||
type: "POST",
|
||||
url: MYSCRIPT.ajaxurl,
|
||||
data: {
|
||||
...{
|
||||
'action': action,
|
||||
'id': postId,
|
||||
token
|
||||
},
|
||||
...data
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** The form is actually sending */
|
||||
let processing = false;
|
||||
|
||||
const listenFormSubmit = (inputs, getData, reset, post_id = null) => {
|
||||
$("input[type=submit]").on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const emailRegex =
|
||||
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
const $formResponse = $(".form__response");
|
||||
|
||||
if (processing === true) {
|
||||
return;
|
||||
}
|
||||
processing = true;
|
||||
|
||||
$formResponse.hide();
|
||||
|
||||
const data = getData();
|
||||
|
||||
const formIsValid = [...Object.entries(getData())]
|
||||
.filter(entry => inputs.optional[entry[0]] === undefined)
|
||||
.reduce((prev, cur) => prev && cur[1].length > 0);
|
||||
const emailIsValid = emailRegex.test(inputs.required.email.val());
|
||||
|
||||
if (!formIsValid) {
|
||||
$formResponse.show();
|
||||
processing = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!emailIsValid) {
|
||||
alert('Le format de l\'adresse email est invalide.');
|
||||
processing = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!window.__CN_Recaptcha_Loaded_Callback) {
|
||||
console.warn('Vous devez activer les cookies recaptcha');
|
||||
alert('Vous devez activer les cookies recaptcha');
|
||||
processing = false;
|
||||
return;
|
||||
}
|
||||
window.__CN_Recaptcha_Loaded_Callback('contact', (token) => ajaxContact(
|
||||
post_id ?? 3941,
|
||||
'ContactAjx',
|
||||
token,
|
||||
data
|
||||
)
|
||||
.done((response, textStatus, jqXHR) => {
|
||||
reset();
|
||||
alert('Message envoyé !');
|
||||
})
|
||||
.fail((jqXHR, textStatus, errorThrown) => {
|
||||
alert('Une erreur est survenue, veuillez recharger la page.');
|
||||
})
|
||||
.always(() => processing = false)
|
||||
);
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const inputs = {
|
||||
required: {
|
||||
subject: $("select[name=Subject]"),
|
||||
company: $("input[name=company]"),
|
||||
lastname: $("input[name=lastname]"),
|
||||
firstname: $("input[name=firstname]"),
|
||||
postcode: $("input[name=postcode]"),
|
||||
city: $("input[name=city]"),
|
||||
email: $("input[name=email]"),
|
||||
phone: $("input[name=phone]"),
|
||||
message: $("textarea[name=message]"),
|
||||
},
|
||||
optional: {
|
||||
newsletter: $("input[name=newsletter]")
|
||||
}
|
||||
};
|
||||
// 'id': 14,
|
||||
listenFormSubmit(
|
||||
// INPUTS
|
||||
inputs,
|
||||
// DATA
|
||||
() => Object.fromEntries([
|
||||
...[
|
||||
...Object.entries(inputs.required),
|
||||
...Object.entries(inputs.optional),
|
||||
].map(entry => [entry[0], entry[1].val()])
|
||||
]),
|
||||
// RESET
|
||||
() => {
|
||||
const resetFn = $input => {
|
||||
if ($input.is("input[type='checkbox']")) {
|
||||
$input.prop("checked", false);
|
||||
return;
|
||||
}
|
||||
if ($input.is("select")) {
|
||||
$input.val($input.children().eq(1).val())
|
||||
return;
|
||||
}
|
||||
$input.val('');
|
||||
};
|
||||
[...Object.values(inputs.required)].forEach(resetFn);
|
||||
[...Object.values(inputs.optional)].forEach(resetFn);
|
||||
},
|
||||
14
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
24
resources/views/front/pages/newsletter-unsubscribe.blade.php
Normal file
24
resources/views/front/pages/newsletter-unsubscribe.blade.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
@extends('front.layouts.layout')
|
||||
|
||||
@section('title', __('Désincription à la newsletter'))
|
||||
@section('description', __('Page de désincription à la newsletter du site le Gaulois'))
|
||||
|
||||
@section('content')
|
||||
<div class="container mt-5 pt-5 mb-3">
|
||||
<div class="row mb-5">
|
||||
<div @class([
|
||||
'col-6 mx-auto alert fw-medium',
|
||||
'alert-danger' => isset($error),
|
||||
'alert-success' => !isset($error)
|
||||
])>
|
||||
<p>
|
||||
@isset($error)
|
||||
{{ $error }}
|
||||
@else
|
||||
{{ __("Votre désinscription a été effectuée avec succès. Si vous changez d'avis, n'hésitez pas à vous réinscrire !") }}
|
||||
@endisset
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\Contact\ContactFormType;
|
||||
use Diglactic\Breadcrumbs\Breadcrumbs;
|
||||
use Diglactic\Breadcrumbs\Generator;
|
||||
use Illuminate\Support\Str;
|
||||
|
|
@ -14,14 +15,27 @@ Breadcrumbs::for('front.homepage', function (Generator $trail) {
|
|||
|
||||
|
||||
// * CONTACT PAGE
|
||||
Breadcrumbs::for('front.contact', function (Generator $trail) {
|
||||
Breadcrumbs::for('front.contact.index', function (Generator $trail) {
|
||||
$trail->parent('front.homepage');
|
||||
$trail->push(
|
||||
Str::of(trans('front.contact'))->ucfirst(),
|
||||
route('front.contact')
|
||||
Str::of(trans('front.contact.index'))->ucfirst(),
|
||||
route('front.contact.index')
|
||||
);
|
||||
});
|
||||
|
||||
Breadcrumbs::for('front.contact.show', function (Generator $trail) {
|
||||
$trail->parent('front.contact.index');
|
||||
$slug = \request()->route()->parameters['slug'];
|
||||
$enumType = collect(ContactFormType::all())->first(function ($enum) use ($slug) {
|
||||
return $enum->slug() === $slug;
|
||||
});
|
||||
if ($slug) {
|
||||
$trail->push(
|
||||
Str::of(trans($enumType->label()))->ucfirst()
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// * SEARCH PAGE
|
||||
Breadcrumbs::for('front.search', function (Generator $trail) {
|
||||
$trail->parent('front.homepage');
|
||||
|
|
|
|||
|
|
@ -10,10 +10,15 @@ Route::name('front.')->group(function () {
|
|||
|
||||
|
||||
|
||||
Route::prefix('nous-contacter')->name('contact.')->group(function() {
|
||||
Route::prefix('nous-contacter')->name('contact.')->group(function () {
|
||||
Route::get('', [ContactController::class, 'index'])->name('index');
|
||||
Route::get('{slug}', [ContactController::class, 'show'])->name('show');
|
||||
Route::post('/', [ContactController::class, 'send'])->name('send');
|
||||
});
|
||||
// * Unsubscribe from newsletter
|
||||
Route::get('/{unsubscribe}', [HomeController::class, 'unsubscribeNewsletter'])
|
||||
->where('unsubscribe', 'unsubscribe|unsubscribe.php|unsubscribe.html|newsletter')
|
||||
->name('unsubscribeNewsletter');
|
||||
|
||||
Route::get('search', function () {
|
||||
return view('front.pages.search');
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export default defineConfig({
|
|||
'resources/ts/back/app.tsx',
|
||||
'resources/sass/back/app.scss',
|
||||
// FRONT
|
||||
'resources/ts/front/app.ts',
|
||||
'resources/ts/front/app.ts'
|
||||
],
|
||||
refresh: true,
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue