Add notify_prize_sent setting
This commit is contained in:
parent
e10acc5756
commit
a5fcfa15e7
7 changed files with 45 additions and 3 deletions
|
|
@ -30,6 +30,7 @@ class UpdateSettingsRequest extends FormRequest
|
|||
// phpcs:enable
|
||||
$this->merge([
|
||||
// Checkboxes.
|
||||
'notify_prize_sent' => $this->boolean('notify_prize_sent'),
|
||||
'use_ean_codes' => $this->boolean('use_ean_codes'),
|
||||
'activated_teaser' => $this->boolean('activated_teaser'),
|
||||
'activated_close_page' => $this->boolean('activated_close_page'),
|
||||
|
|
@ -70,9 +71,10 @@ class UpdateSettingsRequest extends FormRequest
|
|||
'close_page_active_date' => 'nullable|required_if:activated_close_page,true,1|date|after_or_equal:end_date',
|
||||
'redirect_close' => 'required|url:http,https',
|
||||
|
||||
'notify_prize_sent' => 'required|boolean',
|
||||
'discounts_activated' => 'required|boolean',
|
||||
'discounts_site' => 'nullable|required_if:discounts_activated,true,1|string|min:3|max:255',
|
||||
'discounts_campaign' => 'nullable|required_if:discounts_activated,true,1|string|min:3|max:255',
|
||||
'discounts_campaign' => 'nullable|required_if:discounts_activated,true,1|string|min:3|max:255',
|
||||
|
||||
'web_coupons' => [
|
||||
'present', 'array', function ($attribute, $value, $fail) {
|
||||
|
|
@ -142,6 +144,7 @@ class UpdateSettingsRequest extends FormRequest
|
|||
'discounts_activated' => trans('validation.custom.discounts_activated'),
|
||||
'discounts_site' => trans('validation.custom.discounts_site'),
|
||||
'discounts_campaign' => trans('validation.custom.discounts_campaign'),
|
||||
'notify_prize_sent' => trans('validation.custom.notify_prize_sent'),
|
||||
|
||||
'web_coupons' => trans('Tableau des coupons'),
|
||||
'web_coupons.*.web_coupon_identifiant' => trans('Identifiant coupon :index'),
|
||||
|
|
|
|||
|
|
@ -76,8 +76,15 @@ class Participation extends Model
|
|||
});
|
||||
static::updating(function (self $model) {
|
||||
self::manageFields($model);
|
||||
// ? On veux marquer le lot comme envoyé ?
|
||||
if ($model->prize_sent and !$model->getOriginal('prize_sent')) {
|
||||
/** @var \App\Models\Settings */
|
||||
$settings = app(Settings::class);
|
||||
if (
|
||||
// ? Les notification doivent être envoyées ?
|
||||
$settings->notify_prize_sent and
|
||||
// ? On veux marquer le lot comme envoyé ?
|
||||
$model->prize_sent and
|
||||
!$model->getOriginal('prize_sent')
|
||||
) {
|
||||
/** @var \App\Models\Customer */
|
||||
$customer = $model->customer;
|
||||
$customer->notify(new PrizeHasBeenSent());
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ use Illuminate\Support\Facades\Cache;
|
|||
* @property int $nb_unique_code_use Max unique code use (0 = unlimited)
|
||||
* Dans tous les cas 1 joueur ne peut utiliser
|
||||
* qu'une seule fois 1 code donné
|
||||
* @property boolean $notify_prize_sent Should the game send notifications
|
||||
* when the prize is sent ?
|
||||
* @property boolean $use_ean_codes Should the game use ean codes ?
|
||||
* @property boolean $activated_teaser Is the teaser active ?
|
||||
* @property boolean $activated_close_page Is the close page active ?
|
||||
|
|
@ -72,6 +74,7 @@ class Settings extends Model
|
|||
'notification_emails',
|
||||
'winning_proof',
|
||||
'analytics',
|
||||
'notify_prize_sent',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -80,6 +83,7 @@ class Settings extends Model
|
|||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'notify_prize_sent' => 'bool',
|
||||
'use_ean_codes' => 'bool',
|
||||
'activated_teaser' => 'bool',
|
||||
'activated_close_page' => 'bool',
|
||||
|
|
|
|||
|
|
@ -46,6 +46,12 @@ return new class extends Migration
|
|||
|
||||
$table->boolean('winning_proof')
|
||||
->comment('Les preuves de gains sont obligatoires (pdf sont à mettre dans prizes)');
|
||||
|
||||
$table->boolean('notify_prize_sent')
|
||||
->comment(
|
||||
'Envoyer une notification au participants quand leur
|
||||
lot est marqué comme envoyé dans l\'interface'
|
||||
);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class SettingsSeeder extends Seeder
|
|||
$settings->use_ean_codes = false;
|
||||
$settings->activated_teaser = false;
|
||||
$settings->activated_close_page = false;
|
||||
$settings->notify_prize_sent = false;
|
||||
$settings->redirect_close = "https://example.test";
|
||||
$settings->discounts_activated = false;
|
||||
$settings->notification_emails = [];
|
||||
|
|
|
|||
|
|
@ -272,6 +272,7 @@ return [
|
|||
'discounts_campaign' => 'référence de la campagne',
|
||||
'analytics' => 'analytics',
|
||||
'game_rules' => 'règlement du jeu',
|
||||
'notify_prize_sent' => 'notification de lot envoyé au participant',
|
||||
|
||||
'barcode' => 'code-barres du produit',
|
||||
'ticket' => 'ticket de caisse avec la date',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<div class="row mb-3">
|
||||
{{-- CODE VAR --}}
|
||||
<div class="col">
|
||||
<fieldset>
|
||||
<legend>{{ __('Codes configuration') }}</legend>
|
||||
|
|
@ -330,6 +331,25 @@
|
|||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
{{-- NOTIFY_PRIZE_SENT --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.custom.notify_prize_sent')) }}</legend>
|
||||
<div>
|
||||
@include('back::partials.inputs.tinyint-boolean', [
|
||||
'id' => 'notify-prize-sent',
|
||||
'label' => Str::ucfirst(__('validation.custom.notify_prize_sent')),
|
||||
'name' => 'notify_prize_sent',
|
||||
'required' => false,
|
||||
'model' => $settingsModel ?? null,
|
||||
'helper' => __('validation.boolean', [
|
||||
'attribute' => Str::ucfirst(__('validation.custom.notify_prize_sent')),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue