feat: ✨ add newsletter_email field to brands table

This commit is contained in:
Corentin Huet 2026-04-03 17:04:51 +02:00
parent eeddf109f5
commit 98ef3c826e
6 changed files with 99 additions and 43 deletions

View file

@ -10,14 +10,15 @@ use Illuminate\Support\Facades\Cache;
use Uwil\LaravelCommon\Helpers\FileHelper;
/**
* @property integer $id Brand id.
* @property string $name Brand name.
* @property string $logo Brand logo.
* @property string $url Brand url link.
* @property string $url_claim Brand associative url claim.
* @property string $domain Brand domain.
* @property-read \Illuminate\Support\Carbon $created_at Brand created date.
* @property-read \Illuminate\Support\Carbon $updated_at Brand updated date.
* @property integer $id Brand id.
* @property string $name Brand name.
* @property string $logo Brand logo.
* @property string $url Brand url link.
* @property string $url_claim Brand associative url claim.
* @property string $domain Brand domain.
* @property string $newsletter_email Brand associative newsletter email.
* @property-read \Illuminate\Support\Carbon $created_at Brand created date.
* @property-read \Illuminate\Support\Carbon $updated_at Brand updated date.
*
* @property-read \Illuminate\Database\Eloquent\Collection<App\Models\Service>
* $services Service HasMany relation.
@ -46,6 +47,7 @@ class Brand extends Model
'url',
'url_claim',
'domain',
'newsletter_email',
];
/**

View file

@ -22,10 +22,11 @@ class BrandFactory extends Factory
public function definition(): array
{
return [
'name' => $this->faker->unique()->company,
'url' => $this->faker->url,
'url_claim' => $this->faker->url,
'domain' => $this->faker->unique()->domainName,
'name' => $this->faker->unique()->company,
'url' => $this->faker->url,
'url_claim' => $this->faker->url,
'domain' => $this->faker->unique()->domainName,
'newsletter_email' => $this->faker->email
];
}
}

View file

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('brands', function (Blueprint $table) {
$table->string('newsletter_email')->nullable()->comment('Brand associative newsletter email.')->after('domain');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('brands', function (Blueprint $table) {
$table->dropColumn('newsletter_email');
});
}
};

View file

@ -222,20 +222,21 @@ return [
'year' => 'year',
],
'custom' => [
'event' => 'event',
'model' => 'target element',
'order' => 'order',
'publication' => 'publication',
'activated' => 'activated',
'target' => 'target',
'response_type' => 'response type',
'reference' => 'reference',
'type' => 'type',
'status' => 'status',
'label' => 'label',
'domain' => 'domain',
'logo' => 'logo',
'url' => 'url',
'url_claim' => 'claim url',
'event' => 'event',
'model' => 'target element',
'order' => 'order',
'publication' => 'publication',
'activated' => 'activated',
'target' => 'target',
'response_type' => 'response type',
'reference' => 'reference',
'type' => 'type',
'status' => 'status',
'label' => 'label',
'domain' => 'domain',
'logo' => 'logo',
'url' => 'url',
'url_claim' => 'claim url',
'newsletter_email' => 'email address for the newsletter',
],
];

View file

@ -222,20 +222,21 @@ return [
'year' => 'année',
],
'custom' => [
'event' => 'évènement',
'model' => 'élément ciblé',
'order' => 'order',
'publication' => 'publication',
'activated' => 'activé',
'target' => 'cible',
'response_type' => 'type de réponse',
'reference' => 'référence',
'type' => 'type',
'status' => 'status',
'label' => 'libellé',
'domain' => 'domaine',
'logo' => 'logo',
'url' => 'lien',
'url_claim' => 'lien réclamation',
'event' => 'évènement',
'model' => 'élément ciblé',
'order' => 'order',
'publication' => 'publication',
'activated' => 'activé',
'target' => 'cible',
'response_type' => 'type de réponse',
'reference' => 'référence',
'type' => 'type',
'status' => 'status',
'label' => 'libellé',
'domain' => 'domaine',
'logo' => 'logo',
'url' => 'lien',
'url_claim' => 'lien réclamation',
'newsletter_email' => 'adresse email pour la newsletter',
],
];

View file

@ -89,8 +89,31 @@
</div>
</fieldset>
</div>
{{-- NEWSLETTER_EMAIL --}}
<div class="col-12 col-md-6 mb-3">
<fieldset class="h-100 border p-3">
<legend>{{ str(__('validation.custom.newsletter_email'))->ucfirst() }}</legend>
<div class="row">
<div class="col-12 mb-3">
@include('bo.partials.inputs.varchar', [
'id' => 'brandNewsletterEmail',
'label' => __(':field de la :model', [
'field' => str(__('validation.custom.newsletter_email'))->ucfirst(),
'model' => str(__('models.classes.brands'))->singular(),
]),
'hasWordCounter' => true,
'name' => 'newsletter_email',
'required' => false,
'model' => $brandModel ?? null,
'placeholder' => 'no-reply@example.com',
'helper' => __('Adresse email utilisée pour l\'envoi de la newsletter.'),
])
</div>
</div>
</fieldset>
</div>
{{-- IMAGE --}}
<div class="col-12 mb-3">
<div class="col-12 col-md-6 mb-3">
<fieldset class="h-100 border p-3">
<legend>{{ str(__('validation.attributes.image'))->ucfirst() }}</legend>
<div class="row">