Merge branch 'axepta-finish' into 'develop'

Working on #242

See merge request ldc-web/projets/le-gaulois!347
This commit is contained in:
Jérémy 2026-06-23 12:48:46 +00:00
commit 844e643f9e
136 changed files with 1573 additions and 7048 deletions

View file

@ -20,5 +20,6 @@
"titleBar.inactiveBackground": "#0f437e99",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.remoteColor": "#0f437e"
"peacock.remoteColor": "#0f437e",
"intelephense.environment.phpVersion": "8.3.0"
}

View file

@ -25,6 +25,11 @@ use Illuminate\Support\Facades\Log;
class ShopController extends Controller
{
public function __construct(
private readonly AxeptaPayment $aPayment
) {
return parent::__construct();
}
/**
* Shop index.
*
@ -192,13 +197,6 @@ class ShopController extends Controller
// * Convert total in cents
$totalToPay = (int) (\number_format((float) $totalToPay, 2)) * 100;
$aPayment = new AxeptaPayment(
config('axepta.endpoint'),
config('axepta.merchantId'),
config('axepta.apiKey'),
config('axepta.hmac')
);
$aOrder = new AxeptaOrder(
$order->ref,
$totalToPay,
@ -206,7 +204,7 @@ class ShopController extends Controller
);
try {
$payment = $aPayment->getCheckoutUrl(
$payment = $this->aPayment->getCheckoutUrl(
$aOrder,
route('club.shop.reglement.payementConfirmCB', $order),
route('club.shop.reglement.payementConfirmCB', ['order' => $order, 'cancel' => true]),
@ -229,8 +227,8 @@ class ShopController extends Controller
$e->getMessage()
));
return view('club.pages.shop.info')
->with('title', trans('Commande annulée'))
->with('message', trans("Le paiement n'a pu aboutir. Veuillez réessayer"));
->with('title', trans('Commande annulée'))
->with('message', trans("Le paiement n'a pu aboutir. Veuillez réessayer"));
} //end try
}
@ -250,21 +248,14 @@ class ShopController extends Controller
): \Illuminate\Http\Response|\Illuminate\Contracts\Routing\ResponseFactory {
// phpcs:enable
try {
$aPayment = new AxeptaPayment(
config('axepta.endpoint'),
config('axepta.merchantId'),
config('axepta.apiKey'),
config('axepta.hmac')
);
if (!$aPayment->isValidWebhookAccess($request)) {
if (!$this->aPayment->isValidWebhookAccess($request)) {
$order->status = OrderStatus::failed;
$order->save();
// @phpstan-ignore finally.exitPoint
throw new CBPayementError('Data were altered from response');
}
$response = $aPayment->getPaymentStatusById($request->payId);
$response = $this->aPayment->getPaymentStatusById($request->payId);
if (is_null($response)) {
if (
@ -303,10 +294,10 @@ class ShopController extends Controller
}
break;
default:
// * ERROR
// * ERROR
if (
!$order->confirmMailSent and
!$order->status->equals(OrderStatus::payed)
!$order->confirmMailSent and
!$order->status->equals(OrderStatus::payed)
) {
$order->status = OrderStatus::failed;
$order->save();
@ -357,14 +348,7 @@ class ShopController extends Controller
return view('club.pages.shop.validated');
}
$aPayment = new AxeptaPayment(
config('axepta.endpoint'),
config('axepta.merchantId'),
config('axepta.apiKey'),
config('axepta.hmac')
);
$response = $aPayment->getPaymentStatusById($request->PayID);
$response = $this->aPayment->getPaymentStatusById($request->PayID);
if (is_null($response)) {
return view('club.pages.shop.info')

View file

@ -4,13 +4,21 @@ namespace App\Lib\Axepta;
use App\Lib\Axepta\Objects\AxeptaOrder;
use Carbon\Carbon;
use Carbon\CarbonInterface;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Psr\Log\LoggerInterface;
class AxeptaPayment
{
private const int PERMITTED_TIMESTAMP_SKEW_IN_MINUTES = 5;
private const string USING_API_VERSION = 'v1';
/**
* Guzzle Client instance
*
@ -42,8 +50,19 @@ class AxeptaPayment
* @param array $axeptaConfig Additionnal or Update Axepta configuration
* @return void
*/
public function __construct(private string $endpoint, private string $merchantId, private string $apiKey, private string $hmac, private array $axeptaConfig = [])
{
public function __construct(
private readonly LoggerInterface $logger,
#[\SensitiveParameter]
private string $endpoint,
#[\SensitiveParameter]
private string $merchantId,
#[\SensitiveParameter]
private string $apiKey,
#[\SensitiveParameter]
private string $hmac,
#[\SensitiveParameter]
private array $axeptaConfig = []
) {
$this->endpoint = $endpoint;
$this->merchantId = $merchantId;
$this->apiKey = $apiKey;
@ -114,7 +133,7 @@ class AxeptaPayment
$errorData = json_decode($errorBody, true);
$message = $errorData['error'] ?? $errorData['responseDescription'] ?? $e->getMessage();
throw new \RuntimeException("Axepta token error: {$message}", 0, $e);
}//end try
} //end try
}
/**
@ -141,7 +160,7 @@ class AxeptaPayment
"order" => [
"merchantReference" => $order->reference,
"creationDate" => gmdate('c'),
// ISO 8601 now
// ISO 8601 now
],
"customerInfo" => [
"email" => $order->customerEmail,
@ -159,7 +178,7 @@ class AxeptaPayment
'Idempotency-Key' => (string) Str::uuid()
],
'json' => array_merge_recursive($payload, $this->axeptaCheckoutConfig)
// Automatically JSON encodes and sets Content-Type
// Automatically JSON encodes and sets Content-Type
]);
if ($response->getStatusCode() !== 202) {
@ -175,7 +194,7 @@ class AxeptaPayment
return $responseBody->_links->redirect->href;
} catch (RequestException $e) {
throw new \RuntimeException("Payment session error: " . $e->getMessage(), 0, $e);
}//end try
} //end try
}
/**
@ -224,62 +243,7 @@ class AxeptaPayment
} else {
return null;
}
}//end try
}
/**
* Check signature version
*
* https://axepta.computop.com/display/DOCBNP/Gestion+des+callbacks+et+notification+de+paiement
*
* @param string|null $version
* @return boolean
*/
private function isValidSignatureVersion(?string $version): bool
{
return $version === 'v1';
}
/**
* Check signature
*
* https://axepta.computop.com/display/DOCBNP/Gestion+des+callbacks+et+notification+de+paiement
*
* @param string $signature
* @param string $timestamp
* @param string $rawPayload
* @return boolean
*/
private function isValidSignature(string $signature, string $timestamp, string $rawPayload): bool
{
$providedSignature = $this->extractSignature($signature);
if (!$providedSignature) {
return false;
}
$signedPayload = "{$timestamp}.{$rawPayload}";
$expectedSignature = hash_hmac('sha256', $signedPayload, $this->hmac);
return hash_equals($expectedSignature, $providedSignature);
}
/**
* Extract the hex value after "v1=" from the signature header.
*
* https://axepta.computop.com/display/DOCBNP/Gestion+des+callbacks+et+notification+de+paiement
*
* @param string $signature
* @return string|null
*/
private function extractSignature(string $signature): ?string
{
if (!str_starts_with($signature, 'v1=')) {
return null;
}
$hex = substr($signature, 3);
return strlen($hex) === 64 ? $hex : null;
// SHA256 hex = 64 chars
} //end try
}
/**
@ -295,14 +259,143 @@ class AxeptaPayment
* @param \Illuminate\Http\Request $request
* @return boolean
*/
public function isValidWebhookAccess(\Illuminate\Http\Request $request): bool
public function isValidWebhookAccess(Request $request): bool
{
$signatureVersion = $request->header('x-paygate-signature-version');
$timestamp = $request->header('x-paygate-timestamp', '0');
$signature = $request->header('x-paygate-signature');
$signatureVersion = $this->getHeaderValue($request, 'x-paygate-signature-version');
$signature = $this->getHeaderValue($request, 'x-paygate-signature');
$timestamp = $this->getHeaderValue($request, 'x-paygate-timestamp');
$timestamDatetime = Carbon::createFromTimestampUTC($timestamp);
$rawPayload = $request->getContent(false);
return $this->isValidSignatureVersion($signatureVersion) and
Carbon::createFromTimestampUTC($timestamp)->diffInMinutes(Carbon::now('UTC')) <= 5 and
$this->isValidSignature($signature, $timestamp, $request->getContent());
$this->logger->debug(
'Received an IPN call', [
'request_signature_version' => $signatureVersion,
'request_signature' => $signature,
'request_timestamp' => $timestamp,
'request_payload' => $rawPayload
]
);
return $this->isValidSignatureVersion($signatureVersion) &&
$this->requestTimestampIsAcceptable($timestamDatetime) &&
$this->isValidSignature($signature, $timestamDatetime, $rawPayload);
}
/** Get for sure a string value for a specific header name */
private function getHeaderValue(Request $request, string $headerName): string
{
$headerValue = Arr::wrap($request->header($headerName));
$headerValue = Arr::map($headerValue, fn($v) => is_scalar($v) ? strval($v) : '');
return Str::trim(Arr::join($headerValue, ' '));
}
/**
* Check signature version
*
* https://axepta.computop.com/display/DOCBNP/Gestion+des+callbacks+et+notification+de+paiement
*
* @param string|null $version
* @return boolean
*/
private function isValidSignatureVersion(string $version): bool
{
$versionIsValid = $version === self::USING_API_VERSION;
if (!$versionIsValid) {
// NOTE: If this occurs it shall be handled
$this->logger->error(
"Version is not accepted",
[
'request_version' => $version,
'accepted_version' => self::USING_API_VERSION
]
);
}
return $version === self::USING_API_VERSION;
}
private function requestTimestampIsAcceptable(CarbonInterface $timestamp): bool
{
$now = Carbon::now('UTC');
$calculatedDiff = $now->diffInMinutes(date: $timestamp, absolute: true);
$timestampIsInSkew = $calculatedDiff <= self::PERMITTED_TIMESTAMP_SKEW_IN_MINUTES;
if (!$timestampIsInSkew) {
// NOTE: If this occurs it shall be handled
$this->logger->error(
"request timestamp skew is not not matched",
[
'request_timestamp' => $timestamp,
'diff' => $calculatedDiff,
'max_skew_in_minutes' => self::PERMITTED_TIMESTAMP_SKEW_IN_MINUTES
]
);
}
return $timestampIsInSkew;
}
/**
* Check signature
*
* https://axepta.computop.com/display/DOCBNP/Gestion+des+callbacks+et+notification+de+paiement
*
* @param string $signature
* @param \Carbon\CarbonInterface $timestamp
* @param string $rawPayload
* @return boolean
*/
private function isValidSignature(string $signature, CarbonInterface $timestamp, string $rawPayload): bool
{
$providedSignature = $this->extractSignatureFromCurrentVersion($signature);
if (!$providedSignature) {
// NOTE: If this occurs it shall be handled
$this->logger->error(
"Could not extract signature from '{$signature}'"
);
return false;
}
$signedPayload = "{$timestamp}.{$rawPayload}";
$expectedSignature = hash_hmac('sha256', $signedPayload, $this->hmac);
$signatureIsValid = hash_equals($expectedSignature, $providedSignature);
if (!$signatureIsValid) {
// NOTE: If this occurs it could be a fraudulent request
$this->logger->debug(
"{Could not validate that expected signature '{$expectedSignature}' matches the request signature '{$signature}'",
[
'request_signature' => $signature,
'request_timestamp' => $timestamp,
'request_payload' => $rawPayload,
]
);
}
return $signatureIsValid;
}
/**
* Extract the hex value after "v1=" from the signature header.
*
* https://axepta.computop.com/display/DOCBNP/Gestion+des+callbacks+et+notification+de+paiement
*
* @param string $signature
* @return string|null
*/
private function extractSignatureFromCurrentVersion(string $signature): ?string
{
$signatures = explode(',', $signature);
$filteredSignatures = array_filter($signatures, function (string $key) {
return $key === self::USING_API_VERSION;
}, \ARRAY_FILTER_USE_KEY);
$hex = $filteredSignatures[0] ?? '';
// NOTE: SHA256 hex = 64 chars
return strlen($hex) === 64 ? $hex : null;
}
}

View file

@ -60,7 +60,14 @@ class Link implements Jsonable, Arrayable, Stringable
*/
public function getUrl(): string
{
return !is_null($this->url) ? $this->url : route($this->getRouteName());
$url = $this->url;
if (!is_null($url)) {
return $url;
}
$routeName = $this->getRouteName();
return $routeName ? route($routeName) : route('fo.home.show');
}
/**

View file

@ -3,6 +3,7 @@
namespace App\Providers;
use App\Enums\Settings\SettingsType;
use App\Lib\Axepta\AxeptaPayment;
use App\Models\GeneralSetting;
use App\Models\MenuNodeData;
use App\Providers\TelescopeServiceProvider as CustomTelescopeServiceProvider;
@ -12,10 +13,12 @@ use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Config;
use Laravel\Telescope\TelescopeServiceProvider;
use Money\Currencies\ISOCurrencies;
use Money\Currency;
use Money\Formatter\IntlMoneyFormatter;
use Psr\Log\LoggerInterface;
use Snipe\BanBuilder\CensorWords;
class AppServiceProvider extends ServiceProvider
@ -57,6 +60,18 @@ class AppServiceProvider extends ServiceProvider
// * Censor
App::singleton('censor', fn() => new CensorWords());
// * Axepta
$this->app->singleton(AxeptaPayment::class, function () {
$logger = resolve(LoggerInterface::class);
return new AxeptaPayment(
$logger,
Config::string('axepta.endpoint'),
Config::string('axepta.merchantId'),
Config::string('axepta.apiKey'),
Config::string('axepta.hmac')
);
});
$this->setPaymentCurrency();
// * BLADE DIRECTIVES

View file

@ -1,40 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('first_name')->comment('First name of the user.');
$table->string('last_name')->comment('Last name of the user.');
$table->string('email')->unique()->comment('Email of the user.');
$table->timestamp('email_verified_at')->nullable();
$table->string('password')->comment('Password of the user account.');
$table->rememberToken();
$table->unsignedTinyInteger('role')->comment('Role of the user who defines the rights/access.');
$table->boolean('published')->comment('The user is acivated or not.');
$table->timestamp('published_at')->nullable()->comment('The date on which the user was activated.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('users');
}
};

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('password_resets');
}
};

View file

@ -1,70 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return config('telescope.storage.database.connection');
}
/**
* Run the migrations.
*/
public function up(): void
{
$schema = Schema::connection($this->getConnection());
$schema->create('telescope_entries', function (Blueprint $table) {
$table->bigIncrements('sequence');
$table->uuid('uuid');
$table->uuid('batch_id');
$table->string('family_hash')->nullable();
$table->boolean('should_display_on_index')->default(true);
$table->string('type', 20);
$table->longText('content');
$table->dateTime('created_at')->nullable();
$table->unique('uuid');
$table->index('batch_id');
$table->index('family_hash');
$table->index('created_at');
$table->index(['type', 'should_display_on_index']);
});
$schema->create('telescope_entries_tags', function (Blueprint $table) {
$table->uuid('entry_uuid');
$table->string('tag');
$table->primary(['entry_uuid', 'tag']);
$table->index('tag');
$table->foreign('entry_uuid')
->references('uuid')
->on('telescope_entries')
->onDelete('cascade');
});
$schema->create('telescope_monitoring', function (Blueprint $table) {
$table->string('tag')->primary();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
$schema = Schema::connection($this->getConnection());
$schema->dropIfExists('telescope_entries_tags');
$schema->dropIfExists('telescope_entries');
$schema->dropIfExists('telescope_monitoring');
}
};

View file

@ -1,36 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('failed_jobs');
}
};

View file

@ -1,36 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('jobs');
}
};

View file

@ -1,40 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('activity_logs', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->nullable()
->comment('Id of the user associated, or nullable for a deleted user.')
->constrained('users')->nullOnDelete();
$table->boolean('is_anonymous')->comment('If there is no user connected when action was realised.');
$table->boolean('is_console')->comment('If the action was realised in console.');
$table->string('model_class')->comment('Target model.');
$table->integer('model_id')->comment('Id of the target model.');
$table->integer('event')->comment('Event of this activity (ActivityLogsEventEnum).');
$table->json('data')->nullable()->comment('List of changes (old and new values).');
$table->timestamp('created_at')->comment('The date on which the user was published.');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('activity_logs');
}
};

View file

@ -1,37 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('static_pages', function (Blueprint $table) {
$table->id();
$table->unsignedTinyInteger('type')->unique()->comment('Page type (StaticPageEnum)');
$table->string('seo_title')->comment('Seo title about 70 chars as recommended');
$table->string('seo_description')->comment('Seo description about 160 chars as recommended');
$table->string('title')->comment('Title for the page');
$table->string('slug')->unique()->comment('Unique title slug');
$table->text('content')->comment('WYSIWYG text content using ckeditor');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('static_pages');
}
};

View file

@ -1,40 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('brand_advantages', function (Blueprint $table) {
$table->id();
$table->string('title')->comment('Brand advantage title');
$table->string('sustitle')->nullable()->comment('Brand advantage sustitle');
$table->string('picto')->comment('Brand advantage pictogram');
$table->string('picto_alt')->comment('Pictogram alt attribute');
$table->string('picto_title')->comment('Pictogram title attribute');
$table->string('text')->nullable()->comment('Brand advantage text');
$table->boolean('is_large')->comment('Brand advantage block width');
$table->integer('order')->comment('Brand advantage order');
$table->boolean('published')->comment('Brand advantage publish status');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('brand_advantages');
}
};

View file

@ -1,38 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('professions', function (Blueprint $table) {
$table->id();
$table->string('title')->comment('Profession title.');
$table->string('picture')->comment('Profession picture.');
$table->string('picture_alt')->comment('Picture alt attribute.');
$table->string('picture_title')->comment('Picture title attribute.');
$table->text('jobs_list')->comment('Profession list of jobs.');
$table->string('job_url', 300)->comment('Digital recruiters url.');
$table->boolean('published')->comment('Profession publish status.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('professions');
}
};

View file

@ -1,38 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('key_numbers', function (Blueprint $table) {
$table->id();
$table->string('picto')->comment('Picto path.');
$table->string('picto_alt')->comment('Picto alt attribute.');
$table->string('picto_title')->comment('Picto title attribute.');
$table->string('text')->comment('Picto legend.');
$table->string('source')->comment('Text origin.');
$table->integer('order')->comment('Display order bo.');
$table->boolean('published')->comment('Picto publish status.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('key_numbers');
}
};

View file

@ -1,49 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('demarche_slides', function (Blueprint $table) {
$table->id();
$table->string('title')->comment('Slide title.');
$table->string('picture')->comment('Slide picture.');
$table->string('picture_alt')->comment('Slide picture alt attribute.');
$table->string('picture_title')->comment('Slide picture title attribute.');
$table->string('button_1_text')->nullable()->comment('Slide button n°1 text.');
$table->string('button_1_url')->nullable()->comment('Slide button n°1 url.');
$table->string('button_2_text')->nullable()->comment('Slide button n°2 text.');
$table->string('button_2_url')->nullable()->comment('Slide button n°2 url.');
$table->text('text')->comment('Slide text content.');
$table->integer('order')->comment('Slide order.');
#FIXME: add demarche relation
$table->boolean('button_1_status')->comment('Slide button n°1 publish status.');
$table->boolean('button_1_target')->comment('Slide button n°1 target.');
$table->boolean('button_2_status')->comment('Slide button n°2 publish status.');
$table->boolean('button_2_target')->comment('Slide button n°2 target.');
$table->boolean('published')->comment('Slide publish status.');
$table->timestamp('publish_at')->nullable()->comment('Slide publishment date.');
$table->timestamp('unpublish_at')->nullable()->comment('Slide unpublishment date.');
$table->timestamps();
});
}
/**
* Run the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('demarche_slides');
}
};

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('general_settings', function (Blueprint $table) {
$table->unsignedTinyInteger('type')->unique()->comment('General settings enum type (SettingsType).');
$table->json('value')->comment('General settings value (json).');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('general_settings');
}
};

View file

@ -1,47 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('menu_node_data', function (Blueprint $table) {
$table->unsignedSmallInteger('type')
->comment('Enum MenuNodeType, this is unique since we do not use this for links.');
$table->string('sub_label')->comment('(Left part) Link label');
$table->string('title')->comment('(Right part) Sub title');
$table->string('text')->comment('(Right part) Sub text');
$table->unsignedBigInteger('text_color')->comment('(Right part) Sub text color');
$table->string('link_url')->comment('(Right part) Link url');
$table->string('link_title')->comment('(Right part) Link title');
$table->boolean('link_target')->comment('(Right part) Link target');
$table->boolean('link_status')->comment('(Right part) Link status');
$table->string('picture')->comment('(Right part) Picture');
$table->string('picture_alt')->comment('(Right part) Picture alt text');
$table->string('picture_title')->comment('(Right part) Picture title text');
$table->boolean('picture_status')->comment('(Right part) Picture status');
$table->string('background_picture')->comment('(Right part) Menu picture');
$table->string('background_picture_alt')->comment('(Right part) Menu picture alt text');
$table->string('background_picture_title')->comment('(Right part) Menu picture title text');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('menu_node_data');
}
};

View file

@ -1,43 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('ranges', function (Blueprint $table) {
$table->id();
$table->string('label')->comment('Range label.');
$table->string('slug')->comment('Range slug.');
$table->text('description')->comment('Range description.');
$table->string('banner')->comment('Range banner');
$table->string('banner_alt')->comment('Banner alt attribute');
$table->string('banner_title')->comment('Banner title attribute');
$table->string('banner_ambiance')->comment('Range ambiance banner');
$table->string('banner_ambiance_alt')->comment('Ambiance banner alt attribute');
$table->string('banner_ambiance_title')->comment('Ambiance banner title attribute');
$table->unsignedBigInteger('color')->comment('Range associated color.');
$table->integer('order')->comment('Range order');
$table->boolean('published')->comment('Range publish status');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('ranges');
}
};

View file

@ -1,38 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('subranges', function (Blueprint $table) {
$table->id();
$table->string('label')->comment('Subrange label.');
$table->string('slug')->comment('Subrange slug.');
$table->text('description')->comment('Subrange description.');
$table->foreignId('range_id')->comment('Associated range')->constrained()
->onUpdate('no action')->onDelete('restrict');
$table->integer('order')->comment('Subrange order');
$table->boolean('published')->comment('Subrange publish status');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('subranges');
}
};

View file

@ -1,40 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('meats', function (Blueprint $table) {
$table->id();
$table->string('label')->comment('Meat label.');
$table->string('slug')->comment('Meat slug.');
$table->text('description')->comment('Meat description.');
$table->string('banner')->comment('Meat banner');
$table->string('banner_alt')->comment('Banner alt attribute.');
$table->string('banner_title')->comment('Banner title attribute.');
$table->unsignedBigInteger('color')->comment('Meat associated color.');
$table->integer('order')->comment('Meat order.');
$table->boolean('published')->comment('Meat publish status.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('meats');
}
};

View file

@ -1,38 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('submeats', function (Blueprint $table) {
$table->id();
$table->string('label')->comment('Submeat label.');
$table->string('slug')->comment('Submeat slug.');
$table->text('description')->comment('Submeat description.');
$table->foreignId('meat_id')->comment('Associated meat')->constrained()
->onUpdate('no action')->onDelete('restrict');
$table->integer('order')->comment('Submeat order');
$table->boolean('published')->comment('Submeat publish status');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('submeats');
}
};

View file

@ -1,37 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('approaches', function (Blueprint $table) {
$table->id();
$table->unsignedTinyInteger('type')->comment('Approach type (label or demarche).');
$table->string('name')->comment('Approach name.');
$table->string('picture')->comment('Approach picture.');
$table->string('picture_alt')->comment('Picture alt attribute.');
$table->string('picture_title')->comment('Picture title attribute.');
$table->boolean('published')->comment('Approach publication status.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('approaches');
}
};

View file

@ -1,33 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('products', function (Blueprint $table) {
// la table a juste été créée pour permettre la relation avec gammes/viandes/...
$table->id();
$table->string('label')->comment('Product label.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('products');
}
};

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('productables', function (Blueprint $table) {
$table->foreignId('product_id')->comment('The product to associate')->constrained()
->onUpdate('no action')->onDelete('cascade');
$table->morphs('productable');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('productables');
}
};

View file

@ -1,61 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('main_slides', function (Blueprint $table) {
$table->id();
$table->string('title')->comment('Slide title.');
$table->string('subtitle')->comment('Slide subtitle.');
$table->string('background')->comment('Slide background.');
$table->string('background_alt')->comment('Background alt attribute.');
$table->string('background_title')->comment('Background title attribute.');
$table->string('picture')->nullable()->comment('Slide picture.');
$table->string('picture_alt')->nullable()->comment('Picture alt attribute.');
$table->string('picture_title')->nullable()->comment('Picture title attribute.');
$table->string('button_1_text')->nullable()->comment('Slide button n°1 text.');
$table->string('button_1_url')->nullable()->comment('Slide button n°1 url.');
$table->string('button_2_text')->nullable()->comment('Text of the button n°2 in the slide.');
$table->string('button_2_url')->nullable()->comment('Url of the button n°2 in the slide.');
$table->foreignId('approach_id')->nullable()->constrained('approaches')
->onUpdate('cascade')->onDelete('cascade');
$table->unsignedBigInteger('color_block')->comment('Slide block background color.');
$table->unsignedBigInteger('button_1_color_text')->comment('Slide button n°1 text color.');
$table->unsignedBigInteger('button_1_color_background')
->comment('Slide button n°1 background color.');
$table->unsignedBigInteger('button_2_color_text')->comment('Slide button n°2 text color.');
$table->unsignedBigInteger('button_2_color_background')
->comment('Slide button n°2 background color.');
$table->integer('order')->comment('Slide order.');
$table->boolean('button_1_status')->comment('Slide button n°1 publish status.');
$table->boolean('button_1_target')->comment('Slide button n°1 target.');
$table->boolean('button_2_status')->comment('Slide button n°2 publish status.');
$table->boolean('button_2_target')->comment('Open the url of the button n°2 in a new tab.');
$table->boolean('new')->comment('Slide picto new.');
$table->boolean('published')->comment('Slide publish status.');
$table->timestamp('publish_at')->nullable()->comment('Slide publishment date.');
$table->timestamp('unpublish_at')->nullable()->comment('Slide unpublishment date.');
$table->timestamps();
});
}
/**
* Run the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('main_slides');
}
};

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('consumption_moments', function (Blueprint $table) {
$table->id();
$table->string('title')->comment('The title of the consumption moment.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('consumption_moment');
}
};

View file

@ -1,38 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('videos', function (Blueprint $table) {
$table->id();
$table->string('title')->comment('Video title.');
$table->string('video_id')->comment('The video ID.');
$table->boolean('is_on_homepage')->comment('Is display on homepage ?');
$table->foreignId('product_id')->nullable()->comment('Associated product')->constrained()
->onUpdate('no action')->onDelete('cascade');
$table->integer('order')->comment('Video order.');
$table->boolean('published')->comment('Video publish status.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('video');
}
};

View file

@ -1,51 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('recipes', function (Blueprint $table) {
$table->id();
$table->string('slug')->comment('Recipe slug.');
$table->string('title')->comment('Recipe title.');
$table->string('tips')->comment('Recipe tips.');
$table->string('picture')->comment('Recipe picture.');
$table->string('picture_alt')->comment('Picture alt attribute.');
$table->string('picture_title')->comment('Picture title attribute.');
$table->json('ingredients_list')->comment('Recipe list of ingredients.');
$table->text('preparation')->comment('Recipe preparation.');
$table->text('advice')->comment('Recipe advice.');
$table->foreignId('video_id')->nullable()->comment('Recipe video.')->constrained()
->onUpdate('no action')->onDelete('restrict');
$table->foreignId('consumption_moment_id')->comment('Recipe consumption moment.')->constrained()
->onUpdate('no action')->onDelete('restrict');
$table->unsignedSmallInteger('preparation_time')->comment('Recipe preparation time.');
$table->unsignedSmallInteger('cooking_time')->comment('Recipe cooking time.');
$table->unsignedSmallInteger('nb_guests')
->comment('Number of reference persons for ingredient list of the recipe.');
$table->unsignedTinyInteger('difficulty')->comment('Recipe difficulty.');
$table->boolean('highlight')->comment('Recipe highlight.');
$table->boolean('published')->comment('Recipe publish status.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('recipes');
}
};

View file

@ -1,39 +0,0 @@
<?php
use App\Models\ConsumptionMoment;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('consumption_moments', function (Blueprint $table) {
$table->string('slug')->comment('Consumption moment title slug.')->after('title');
});
ConsumptionMoment::query()->get()->each(function (ConsumptionMoment $consumptionMoment) {
$consumptionMoment->slug = Str::slug($consumptionMoment->title);
$consumptionMoment->saveQuietly();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('consumption_moments', function (Blueprint $table) {
$table->dropColumn('slug');
});
}
};

View file

@ -1,50 +0,0 @@
<?php
use App\Lib\Helpers\FileStorageHelper;
use App\Models\StaticPage;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('static_pages', function (Blueprint $table) {
$table->string('subtitle')->after('slug')->comment('The static page subtitle.');
$table->string('picture')->after('subtitle')->comment('Picture path.');
$table->string('picture_alt')->after('picture')->comment('Picture alt attribute.');
$table->string('picture_title')->after('picture_alt')->comment('Picture title attribute.');
});
StaticPage::query()->get()->map(function ($satic_page_Model) {
$satic_page_Model->subtitle = fake()->sentence();
$satic_page_Model->picture = FileStorageHelper::storeFile(
new StaticPage(),
new \SplFileInfo(
\resource_path('../database/factories/assets/recipes/default-picture-720x405.png')
)
);
$satic_page_Model->picture_alt = "text alternatif de l'image";
$satic_page_Model->picture_title = "titre de l'image";
$satic_page_Model->saveQuietly();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('static_pages', function (Blueprint $table) {
$table->dropColumn(['picture', 'picture_alt', 'picture_title', 'subtitle']);
});
}
};

View file

@ -1,48 +0,0 @@
<?php
use Database\Seeders\Development\ProductTypeSeeder;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('product_types', function (Blueprint $table) {
$table->id();
$table->string('label')->comment('Product type description.');
$table->text('description')->comment('Product type description.');
$table->string('picture')->comment('Product type picture.');
$table->string('picture_alt')->comment('Picture alt attribute.');
$table->string('picture_title')->comment('Picture title attribute.');
$table->boolean('button_status')->comment('Product type button publish status.');
$table->timestamps();
});
Schema::table('product_types', function (Blueprint $table) {
$table->boolean('published')->comment('Product type publish status.')->after('button_status');
});
// Call seeder.
Artisan::call('db:seed', [
'--class' => ProductTypeSeeder::class,
]);
}
/**
* Run the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('product_types');
}
};

View file

@ -1,40 +0,0 @@
<?php
use Database\Seeders\Development\ClaimSeeder;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('claims', function (Blueprint $table) {
$table->id();
$table->string('label')->comment('Claim label.');
$table->boolean('published')->comment('Claim publish status.');
$table->timestamps();
});
// Call seeder.
Artisan::call('db:seed', [
'--class' => ClaimSeeder::class,
]);
}
/**
* Run the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('claims');
}
};

View file

@ -1,170 +0,0 @@
<?php
use App\Enums\Approaches\ApproachTypeEnum;
use App\Lib\Helpers\FileStorageHelper;
use App\Models\Approach;
use App\Models\Claim;
use App\Models\Product;
use App\Models\ProductType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('products', function (Blueprint $table) {
$table->string('picture')->after('label')->comment('Product picture.');
$table->string('picture_alt')->after('picture')->comment('Picture alt attribute.');
$table->string('picture_title')->after('picture_alt')->comment('Picture title attribute.');
$table->string('banner')->after('picture_title')->comment('Product banner.');
$table->string('banner_alt')->after('banner')->comment('Banner alt attribute.');
$table->string('banner_title')->after('banner_alt')->comment('Banner title attribute.');
$table->string('packaging')->after('banner_title')->comment('Product packaging.');
$table->string('packaging_alt')->after('packaging')->comment('Packaging alt attribute.');
$table->string('packaging_title')->after('packaging_alt')->comment('Packaging title attribute.');
});
Schema::table('products', function (Blueprint $table) {
$table->text('description')->after('packaging_title')->comment('Product description.');
$table->text('details')->after('description')->comment('Product details.');
$table->text('preparation')->after('details')->comment('Product preparation.');
$table->text('ingredients')->after('preparation')->comment('Product ingrédients.');
});
Schema::table('products', function (Blueprint $table) {
$table->foreignId('approach_id')->nullable()->after('ingredients')
->comment('Product approach (demarche).')
->constrained()->onUpdate('cascade')->onDelete('cascade');
$table->boolean('new')->after('approach_id')->nullable()->comment('Product new.');
$table->boolean('discover')->after('new')->comment('Product discover.');
$table->boolean('published')->after('discover')->comment('Product publish status.');
});
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\Approach> $approachLabels */
$approachLabels = Approach::query()
->where('published', true)
->where('type', ApproachTypeEnum::label)
->get();
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\Approach> $approachDemarches */
$approachDemarches = Approach::query()
->where('type', ApproachTypeEnum::demarche)
->where('published', true)
->get();
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\ProductType> $productTypeModels */
$productTypeModels = ProductType::query()->get();
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\Claim> $claimModels */
$claimModels = Claim::query()->where('published', true)->get();
Product::query()->get()->map(function (Product $productModel) use (
$approachLabels,
$productTypeModels,
$claimModels,
$approachDemarches,
) {
$productModel->description = "description du produit";
$productModel->details = "détails du produit";
$productModel->preparation = "préparation du produit";
$productModel->ingredients = "ingrédients du produit";
$productModel->picture = FileStorageHelper::storeFile(
$productModel,
new \SplFileInfo(\resource_path(
'../database/factories/assets/products/default-picture-1440x420.png'
))
);
$productModel->picture_alt = "attribut alt de l'image";
$productModel->picture_title = "attribut titre de l'image";
$productModel->banner = FileStorageHelper::storeFile(
$productModel,
new \SplFileInfo(\resource_path(
'../database/factories/assets/products/default-picture-1440x420.png'
))
);
$productModel->banner_alt = "attribut alt de l'image";
$productModel->banner_title = "attribut titre de l'image";
$productModel->packaging = FileStorageHelper::storeFile(
$productModel,
new \SplFileInfo(\resource_path(
'../database/factories/assets/products/default-picture-1440x420.png'
))
);
$productModel->packaging_alt = "attribut alt de l'image";
$productModel->packaging_title = "attribut titre de l'image";
$productModel->approach_id = rand(0, 1)
? collect($approachDemarches->random(1))->first()->getKey()
: null;
$productModel->new = rand(0, 1);
$productModel->discover = rand(0, 1);
$productModel->published = rand(0, 1);
$productModel->saveQuietly();
// Morph relationships (approach->label).
for ($i = 0; $i <= rand(0, count($approachLabels)); $i++) {
DB::table('productables')->insert(
[
'product_id' => $productModel->getKey(),
'productable_id' => collect($approachLabels->random(1))->first()->getKey(),
'productable_type' => 'App\Models\Approach'
]
);
}
// Morph relationships (productType).
for ($i = 0; $i <= rand(0, count($productTypeModels)); $i++) {
DB::table('productables')->insert(
[
'product_id' => $productModel->getKey(),
'productable_id' => collect($productTypeModels->random(1))->first()->getKey(),
'productable_type' => 'App\Models\ProductType'
]
);
}
// Morph relationships (claim).
for ($i = 0; $i <= rand(0, count($claimModels)); $i++) {
DB::table('productables')->insert(
[
'product_id' => $productModel->getKey(),
'productable_id' => collect($claimModels->random(1))->first()->getKey(),
'productable_type' => 'App\Models\Claim'
]
);
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('description');
$table->dropColumn('details');
$table->dropColumn('preparation');
$table->dropColumn('picture');
$table->dropColumn('picture_alt');
$table->dropColumn('picture_title');
$table->dropColumn('banner');
$table->dropColumn('banner_alt');
$table->dropColumn('banner_title');
$table->dropColumn('packaging');
$table->dropColumn('packaging_alt');
$table->dropColumn('packaging_title');
$table->dropForeign(['approach_id']);
$table->dropColumn('approach_id');
$table->dropColumn('new');
$table->dropColumn('discover');
$table->dropColumn('published');
});
$arraySQL = ['Approach', 'ProductType', 'Claim'];
foreach ($arraySQL as $value) {
DB::statement('DELETE FROM `productables` WHERE `productable_type` LIKE "%' . $value . '"');
}
}
};

View file

@ -1,38 +0,0 @@
<?php
use App\Enums\Settings\SettingsType;
use App\Models\GeneralSetting;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
collect([SettingsType::products, SettingsType::product])->map(function (SettingsType $enum) {
(new GeneralSetting())->insert([
'type' => $enum,
'value' => json_encode(GeneralSetting::getJsonLayout($enum)),
'created_at' => now(),
'updated_at' => now()
]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
collect([SettingsType::products, SettingsType::product])->map(function (SettingsType $enum) {
DB::statement('DELETE FROM `general_settings` WHERE `type` LIKE "' . $enum->value() . '"');
});
}
};

View file

@ -1,58 +0,0 @@
<?php
use Database\Seeders\Development\IncoNutritionalValueSeeder;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('inco_nutritional_values', function (Blueprint $table) {
$table->id()->comment('Inco id.');
$table->foreignId('product_id')->nullable()->comment('Inco product id.')
->constrained()->onUpdate('cascade')->onDelete('cascade');
$table->double('energy')->nullable()->comment('Inco energy value.');
$table->double('energy_kj')->nullable()->comment('Inco energy (kj) value.');
$table->double('protein')->nullable()->comment('Inco protein value.');
$table->double('carbohydrates')->nullable()->comment('Inco carbohydrates value.');
$table->double('sugar')->nullable()->comment('Inco sugar value.');
$table->double('fat')->nullable()->comment('Inco fat value.');
$table->double('saturated_fatty_acids')->nullable()->comment('Inco saturated fatty acids value.');
$table->double('dietary_fiber')->nullable()->comment('Inco dietary fiber value.');
$table->double('salt')->nullable()->comment('Inco salt value.');
$table->float('salt_percent')->nullable()->comment('Inco salt percent.');
$table->float('energy_percent')->nullable()->comment('Inco energy percent value.');
$table->float('energy_kj_percent')->nullable()->comment('Inco energy (kj) percent value.');
$table->float('protein_percent')->nullable()->comment('Inco protein percent value.');
$table->float('carbohydrates_percent')->nullable()->comment('Inco carbohydrates percent value.');
$table->float('sugar_percent')->nullable()->comment('Inco salt percent value.');
$table->float('fat_percent')->nullable()->comment('Inco fat percent value.');
$table->float('saturated_fatty_acids_percent')->nullable()
->comment('Inco saturated fatty acids percent value.');
$table->float('dietary_fiber_percent')->nullable()->comment('Inco dietary fiber percent value.');
$table->timestamps();
});
Artisan::call('db:seed', [
'--class' => IncoNutritionalValueSeeder::class,
]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('inco_nutritional_values');
}
};

View file

@ -1,82 +0,0 @@
<?php
use App\Enums\Approaches\ApproachTypeEnum;
use App\Enums\Settings\SettingsType;
use App\Enums\StaticPageType;
use App\Lib\Helpers\FileStorageHelper;
use App\Models\Approach;
use App\Models\GeneralSetting;
use App\Models\StaticPage;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
// Add recipe/recipes settings type.
collect([SettingsType::recipes, SettingsType::recipe])->map(function (SettingsType $enum) {
(new GeneralSetting())->insert([
'type' => $enum,
'value' => json_encode(GeneralSetting::getJsonLayout($enum)),
'created_at' => now(),
'updated_at' => now()
]);
});
// Add sage static page.
(new StaticPage())->insert([
'seo_title' => sprintf('Seo title pour la page %s', StaticPageType::saga->label()),
'seo_description' => sprintf('Seo description pour la page %s', StaticPageType::saga->label()),
'title' => StaticPageType::saga->label(),
'type' => StaticPageType::saga,
'slug' => Str::slug(StaticPageType::saga->label()),
'subtitle' => fake()->sentence(),
'picture' => FileStorageHelper::storeFile(
new StaticPage(),
new \SplFileInfo(
\resource_path('../database/factories/assets/recipes/default-picture-720x405.png')
)
),
'picture_alt' => "text alternatif de l'image",
'picture_title' => "titre de l'image",
'content' => \clean(\fake()->randomHtml()),
]);
Approach::query()->where('type', 1)->get()->map(function (Approach $approachModel) {
$approachModel->type = ApproachTypeEnum::demarche;
$approachModel->saveQuietly();
});
Approach::query()->where('type', 0)->get()->map(function (Approach $approachModel) {
$approachModel->type = ApproachTypeEnum::label;
$approachModel->saveQuietly();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
collect([SettingsType::recipes, SettingsType::recipe])->map(function (SettingsType $enum) {
DB::statement('DELETE FROM `general_settings` WHERE `type` LIKE "' . $enum->value() . '"');
});
DB::statement('DELETE FROM `static_pages` WHERE `type` LIKE "' . StaticPageType::saga->value() . '"');
Approach::query()->where('type', ApproachTypeEnum::label)->get()->map(function (Approach $approachModel) {
$approachModel->type = 0;
$approachModel->saveQuietly();
});
Approach::query()->where('type', ApproachTypeEnum::demarche)->get()->map(function (Approach $approachModel) {
$approachModel->type = 1;
$approachModel->saveQuietly();
});
}
};

View file

@ -1,74 +0,0 @@
<?php
use App\Lib\Helpers\FileStorageHelper;
use App\Models\Product;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Product::query()->get()->map(function (Product $productModel) {
FileStorageHelper::removeFile($productModel, 'picture');
FileStorageHelper::removeOldFile($productModel, 'banner');
FileStorageHelper::removeOldFile($productModel, 'packaging');
$productModel->picture = FileStorageHelper::storeFile(
$productModel,
new \SplFileInfo(\resource_path(
'../database/factories/assets/products/default-picture-300x200.png'
))
);
$productModel->banner = FileStorageHelper::storeFile(
$productModel,
new \SplFileInfo(\resource_path(
'../database/factories/assets/products/default-picture-1440x420.png'
))
);
$productModel->packaging = FileStorageHelper::storeFile(
$productModel,
new \SplFileInfo(\resource_path(
'../database/factories/assets/products/default-picture-315x450.png'
))
);
$productModel->saveQuietly();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Product::query()->get()->map(function (Product $productModel) {
FileStorageHelper::removeFile($productModel, 'picture');
FileStorageHelper::removeOldFile($productModel, 'banner');
FileStorageHelper::removeOldFile($productModel, 'packaging');
$productModel->picture = FileStorageHelper::storeFile(
$productModel,
new \SplFileInfo(\resource_path(
'../database/factories/assets/products/default-picture-1440x420.png'
))
);
$productModel->banner = FileStorageHelper::storeFile(
$productModel,
new \SplFileInfo(\resource_path(
'../database/factories/assets/products/default-picture-1440x420.png'
))
);
$productModel->packaging = FileStorageHelper::storeFile(
$productModel,
new \SplFileInfo(\resource_path(
'../database/factories/assets/products/default-picture-1440x420.png'
))
);
$productModel->saveQuietly();
});
}
};

View file

@ -1,38 +0,0 @@
<?php
use App\Models\Product;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('products', function (Blueprint $table) {
$table->string('slug')->comment('Product slug.')->after('label');
});
Product::query()->get()->map(function (Product $productModel) {
$productModel->slug = Str::slug($productModel->label);
$productModel->saveQuietly();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('slug');
});
}
};

View file

@ -1,97 +0,0 @@
<?php
use App\Models\Meat;
use App\Models\Product;
use App\Models\Range;
use App\Models\Submeat;
use App\Models\Subrange;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('products', function (Blueprint $table) {
$table->foreignId('meat_id')->nullable()->after('ingredients')
->comment('Product meat.')
->constrained()->onUpdate('cascade')->onDelete('cascade');
$table->foreignId('submeat_id')->nullable()->after('meat_id')
->comment('Product submeat.')
->constrained()->onUpdate('cascade')->onDelete('cascade');
$table->foreignId('range_id')->nullable()->after('submeat_id')
->comment('Product range.')
->constrained()->onUpdate('cascade')->onDelete('cascade');
$table->foreignId('subrange_id')->nullable()->after('range_id')
->comment('Product subrange.')
->constrained()->onUpdate('cascade')->onDelete('cascade');
});
DB::statement('DELETE FROM `productables` WHERE `productable_type` LIKE "%range"');
DB::statement('DELETE FROM `productables` WHERE `productable_type` LIKE "%meat"');
$rangeModels = Range::query()->get();
$subrangeModels = Subrange::query()->get();
$meatModels = Meat::query()->get();
$submeatModels = Submeat::query()->get();
Product::query()->get()->map(function (Product $productModel) use (
$rangeModels,
$subrangeModels,
$meatModels,
$submeatModels,
) {
(rand(0, 1))
? $productModel->range_id = collect($rangeModels->random(1))->first()->getKey()
: $productModel->subrange_id = collect($subrangeModels->random(1))->first()->getKey();
(rand(0, 1))
? $productModel->meat_id = collect($meatModels->random(1))->first()->getKey()
: $productModel->submeat_id = collect($submeatModels->random(1))->first()->getKey();
$productModel->saveQuietly();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('products', function (Blueprint $table) {
$table->dropForeign(['meat_id']);
$table->dropColumn('meat_id');
$table->dropForeign(['submeat_id']);
$table->dropColumn('submeat_id');
$table->dropForeign(['range_id']);
$table->dropColumn('range_id');
$table->dropForeign(['subrange_id']);
$table->dropColumn('subrange_id');
});
$rangeModels = Range::query()->where('published', true)->get();
$subrangeModels = Subrange::query()->where('published', true)->get();
Product::query()->get()->map(function (Product $productModel) use ($rangeModels, $subrangeModels) {
if (rand(0, 1)) {
DB::table('productables')->insert(
[
'product_id' => $productModel->getKey(),
'productable_id' => collect($rangeModels->random(1))->first()->getKey(),
'productable_type' => "App\Models\Range"
]
);
} else {
DB::table('productables')->insert(
[
'product_id' => $productModel->getKey(),
'productable_id' => collect($subrangeModels->random(1))->first()->getKey(),
'productable_type' => "App\Models\Subrange"
]
);
}
});
}
};

View file

@ -1,39 +0,0 @@
<?php
use App\Models\ProductType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
if (!Schema::hasColumn('product_types', 'published')) {
Schema::table('product_types', function (Blueprint $table) {
$table->boolean('published')->comment('Product type publish status.')->after('button_status');
});
}
ProductType::query()->get()->map(function (ProductType $productTypeModel) {
$productTypeModel->published = true;
$productTypeModel->saveQuietly();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('product_types', function (Blueprint $table) {
$table->dropColumn('published');
});
}
};

View file

@ -1,65 +0,0 @@
<?php
use App\Enums\Settings\MenuNodeType;
use App\Enums\Settings\SettingsType;
use App\Lib\Link;
use App\Models\GeneralSetting;
use Database\Seeders\Mandatory\GeneralSettingSeeder;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Artisan;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
* @throws \Exception In general settings menu is missing.
*/
public function up(): void
{
$query = GeneralSetting::query()->where('type', SettingsType::mainMenu);
if (!(clone $query)->exists()) {
Artisan::call('db:seed', [
'class' => GeneralSettingSeeder::class
]);
}
/** @var \App\Models\GeneralSetting|null */
$generalSettingModel = GeneralSetting::query()->where('type', SettingsType::mainMenu)->first();
if (!$generalSettingModel) {
throw new \Exception('Missing generalSettings ' . SettingsType::mainMenu->label());
}
$generalSettingModel->value = collect($generalSettingModel->value)->map(function (\stdClass $item) {
if ($item->type->equals(MenuNodeType::ourProducts)) {
$item->link = (new Link(routeName: MenuNodeType::ourProducts->routeName()))->toArray();
} elseif ($item->type->equals(MenuNodeType::ourRecipes)) {
$item->link = (new Link(routeName: MenuNodeType::ourRecipes->routeName()))->toArray();
} elseif ($item->type->equals(MenuNodeType::recruitment)) {
$item->link = (new Link(routeName: MenuNodeType::recruitment->routeName()))->toArray();
}
return $item;
});
$generalSettingModel->saveQuietly();
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
$generalSettingModel = GeneralSetting::query()->where('type', SettingsType::mainMenu)->first();
$generalSettingModel->value = collect($generalSettingModel->value)->map(function ($item) {
if (
$item->type->equals(MenuNodeType::ourProducts)
|| $item->type->equals(MenuNodeType::ourRecipes)
|| $item->type->equals(MenuNodeType::recruitment)
) {
$item->link = (new Link(routeName: 'fo.contact.show'))->toArray();
}
return $item;
});
$generalSettingModel->saveQuietly();
}
};

View file

@ -1,33 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('approaches', function (Blueprint $table) {
$table->string('button_url')->nullable()->after('picture_title')
->comment('Approach button url (only for demarche).');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('approaches', function (Blueprint $table) {
$table->dropColumn('button_url');
});
}
};

View file

@ -1,156 +0,0 @@
<?php
use App\Lib\Helpers\FileStorageHelper;
use App\Models\ConsumptionMoment;
use App\Models\Meat;
use App\Models\Range;
use App\Models\Submeat;
use App\Models\Subrange;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('consumption_moments', function (Blueprint $table) {
$table->string('subtitle')->after('title')->comment('Consumption moment subtitle of the page.');
$table->text('description')->after('slug')->comment('Consumption moment description of the page.');
$table->string('picture')->after('description')->comment('Consumption moment picture.');
$table->string('picture_alt')->after('picture')->comment('Picture alt attribute.');
$table->string('picture_title')->after('picture_alt')->comment('Picture title attribute.');
});
Schema::table('meats', function (Blueprint $table) {
$table->string('subtitle')->after('label')->comment('Meat subtitle of the page.');
$table->string('picture')->after('banner_title')->comment('Meat picture.');
$table->string('picture_alt')->after('picture')->comment('Picture alt attribute.');
$table->string('picture_title')->after('picture_alt')->comment('Picture title attribute.');
});
Schema::table('submeats', function (Blueprint $table) {
$table->string('subtitle')->after('label')->comment('Submeat subtitle of the page.');
$table->string('picture')->after('description')->comment('Submeat picture.');
$table->string('picture_alt')->after('picture')->comment('Picture alt attribute.');
$table->string('picture_title')->after('picture_alt')->comment('Picture title attribute.');
});
Schema::table('ranges', function (Blueprint $table) {
$table->string('subtitle')->after('label')->comment('Range subtitle of the page.');
$table->string('picture')->after('banner_ambiance_title')->comment('Range picture.');
$table->string('picture_alt')->after('picture')->comment('Picture alt attribute.');
$table->string('picture_title')->after('picture_alt')->comment('Picture title attribute.');
});
Schema::table('subranges', function (Blueprint $table) {
$table->string('subtitle')->after('label')->comment('Subrange subtitle of the page.');
$table->string('picture')->after('description')->comment('Subrange picture.');
$table->string('picture_alt')->after('picture')->comment('Picture alt attribute.');
$table->string('picture_title')->after('picture_alt')->comment('Picture title attribute.');
});
ConsumptionMoment::query()->get()->map(function (ConsumptionMoment $model) {
$model->subtitle = "Sous-titre moment de consommation";
$model->description = "Description moment de consommation";
$model->picture = FileStorageHelper::storeFile(
$model,
new \SplFileInfo(\resource_path(
'../database/factories/assets/consumption_moments/default-picture-720x405.png'
))
);
$model->picture_alt = "text alternatif de l'image";
$model->picture_title = "titre de l'image";
$model->saveQuietly();
});
Meat::query()->get()->map(function (Meat $model) {
$model->subtitle = "Sous-titre viande";
$model->picture = FileStorageHelper::storeFile(
$model,
new \SplFileInfo(\resource_path(
'../database/factories/assets/meats/default-picture-720x405.png'
))
);
$model->picture_alt = "text alternatif de l'image";
$model->picture_title = "titre de l'image";
$model->saveQuietly();
});
Submeat::query()->get()->map(function (Submeat $model) {
$model->subtitle = "Sous-titre sous-viande";
$model->picture = FileStorageHelper::storeFile(
$model,
new \SplFileInfo(\resource_path(
'../database/factories/assets/submeats/default-picture-720x405.png'
))
);
$model->picture_alt = "text alternatif de l'image";
$model->picture_title = "titre de l'image";
$model->saveQuietly();
});
Range::query()->get()->map(function (Range $model) {
$model->subtitle = "Sous-titre gamme";
$model->picture = FileStorageHelper::storeFile(
$model,
new \SplFileInfo(\resource_path(
'../database/factories/assets/ranges/default-picture-720x405.png'
))
);
$model->picture_alt = "text alternatif de l'image";
$model->picture_title = "titre de l'image";
$model->saveQuietly();
});
Subrange::query()->get()->map(function (Subrange $model) {
$model->subtitle = "Sous-titre sous-gamme";
$model->picture = FileStorageHelper::storeFile(
$model,
new \SplFileInfo(\resource_path(
'../database/factories/assets/subranges/default-picture-720x405.png'
))
);
$model->picture_alt = "text alternatif de l'image";
$model->picture_title = "titre de l'image";
$model->saveQuietly();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('consumption_moments', function (Blueprint $table) {
$table->dropColumn('subtitle');
$table->dropColumn('description');
$table->dropColumn('picture');
$table->dropColumn('picture_alt');
$table->dropColumn('picture_title');
});
Schema::table('meats', function (Blueprint $table) {
$table->dropColumn('subtitle');
$table->dropColumn('picture');
$table->dropColumn('picture_alt');
$table->dropColumn('picture_title');
});
Schema::table('submeats', function (Blueprint $table) {
$table->dropColumn('subtitle');
$table->dropColumn('picture');
$table->dropColumn('picture_alt');
$table->dropColumn('picture_title');
});
Schema::table('ranges', function (Blueprint $table) {
$table->dropColumn('subtitle');
$table->dropColumn('picture');
$table->dropColumn('picture_alt');
$table->dropColumn('picture_title');
});
Schema::table('subranges', function (Blueprint $table) {
$table->dropColumn('subtitle');
$table->dropColumn('picture');
$table->dropColumn('picture_alt');
$table->dropColumn('picture_title');
});
}
};

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('csutomer_password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('csutomer_password_resets');
}
};

View file

@ -1,37 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('customers', function (Blueprint $table) {
$table->id();
$table->string('email')->unique()->comment('Customer unique email');
$table->uuid('hashcode')->unique()->comment('Customer unique CRM hashcode');
$table->string('username')->unique()->comment('Customer unique username');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('customers');
}
};

View file

@ -1,34 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddDateFiledsOnCustomers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('customers', function (Blueprint $table) {
$table->timestamp('email_verified_at')->nullable()->after('remember_token');
$table->timestamp('last_connection')->nullable()->after('email_verified_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('customers', function (Blueprint $table) {
$table->dropColumn('email_verified_at');
$table->dropColumn('last_connection');
});
}
}

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddSoftDeleteToCustomers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('customers', function (Blueprint $table) {
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('customers', function (Blueprint $table) {
$table->dropSoftDeletes();
});
}
}

View file

@ -1,27 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::rename('csutomer_password_resets', 'customer_password_resets');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::rename('customer_password_resets', 'csutomer_password_resets');
}
};

View file

@ -1,33 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('customers', function (Blueprint $table) {
// FIXME: Pour dev maquette, A enlever lors de la mise ne place CRM.
$table->string('password')->comment('A enlever lors de la mise ne place CRM');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('customers', function (Blueprint $table) {
$table->dropColumn('password');
});
}
};

View file

@ -1,38 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('historical_milestones', function (Blueprint $table) {
$table->id();
$table->year('year')->comment('Historical milestone year.');
$table->string('title')->comment('Historical milestone title.');
$table->text('description')->comment('Historical milestone description.');
$table->string('picture')->comment('Historical milestone picture.');
$table->string('picture_alt')->comment('Picture alt attribute.');
$table->string('picture_title')->comment('Picture title attribute.');
$table->boolean('published')->comment('Historical milestone publish status.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('historical_milestones');
}
};

View file

@ -1,223 +0,0 @@
<?php
use App\Enums\InputType;
use App\Enums\StaticPageType;
use App\Models\StaticPage;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('static_pages', function (Blueprint $table) {
$table->string('seo_title')->nullable()->comment('Static page SEO title.')->change();
$table->string('seo_description')->nullable()->comment('Static page SEO description.')->change();
$table->string('title')->nullable()->comment('Static page title.')->change();
$table->string('subtitle', 500)->nullable()->comment('Static page subtitle.')->change();
$table->string('picture')->nullable()->comment('Static page picture.')->change();
$table->string('picture_alt')->nullable()->comment('Picture alt attribute.')->change();
$table->string('picture_title')->nullable()->comment('Picture title attribute.')->change();
$table->text('content')->nullable()->comment('Static page content.')->change();
$table->mediumText('data')->nullable()->after('content')->comment('Static page data.');
});
// SAGA.
$staticPage = StaticPage::query()->where('type', StaticPageType::saga)->first();
$staticPage->seo_title = "Seo title pour la page Saga publicitaire";
$staticPage->seo_description = sprintf(
"Seo description pour la page Saga publicitaire du site %s",
config('app.name')
);
$staticPage->title = "Saga";
$staticPage->subtitle = "Sous-titre";
$staticPage->slug = "saga";
$staticPage->picture = null;
$staticPage->picture_alt = null;
$staticPage->picture_title = null;
$staticPage->content = "Contenu";
$staticPage->data = [
"title_content" => [
"label" => "Titre du contenu",
"inputType" => InputType::string->value,
"value" => "le titre du contenu",
"validate" => "required|string|between:3,255",
'required' => true
],
];
$staticPage->saveQuietly();
// RECIPES.
$staticPage = new StaticPage();
$staticPage->type = StaticPageType::recipes;
$staticPage->seo_title = "Seo title pour la page des Recettes";
$staticPage->seo_description = sprintf("Seo description pour la page Recettes du site %s", config('app.name'));
$staticPage->title = "Recettes";
$staticPage->subtitle = "le sous-titre par défaut des recettes";
$staticPage->slug = "recipes";
$staticPage->picture = null;
$staticPage->picture_alt = null;
$staticPage->picture_title = null;
$staticPage->content = "le texte par défaut des recettes";
$staticPage->data = [];
$staticPage->saveQuietly();
// RECIPE.
$staticPage = new StaticPage();
$staticPage->type = StaticPageType::recipe;
$staticPage->seo_title = "Seo title pour la page d'une Recette";
$staticPage->seo_description = sprintf("Seo description pour la page Recette du site %s", config('app.name'));
$staticPage->title = "Recette";
$staticPage->subtitle = "Sous-titre";
$staticPage->slug = "recipe";
$staticPage->picture = null;
$staticPage->picture_alt = null;
$staticPage->picture_title = null;
$staticPage->content = null;
$staticPage->data = [
"tips_title" => [
"label" => "Titre de l'astuce",
"inputType" => InputType::string->value,
"value" => "le titre de l'astuce",
"validate" => "required|string|between:3,255",
'required' => true
],
"recipes_title" => [
"label" => "Titre des autres recettes",
"inputType" => InputType::string->value,
"value" => "le titre des autres recettes",
"validate" => "required|string|between:3,255",
'required' => true
],
"text" => [
"label" => "Texte des autres recettes",
"inputType" => InputType::text->value,
"value" => "le texte des autres recettes",
"validate" => 'required|string',
'required' => true
]
];
$staticPage->saveQuietly();
// PRODUCTS.
$staticPage = new StaticPage();
$staticPage->type = StaticPageType::products;
$staticPage->seo_title = "Seo title pour la page des Produits";
$staticPage->seo_description = sprintf("Seo description pour la page Produits du site %s", config('app.name'));
$staticPage->title = "Produits";
$staticPage->subtitle = "le sous-titre par défaut des produits";
$staticPage->slug = "products";
$staticPage->picture = null;
$staticPage->picture_alt = null;
$staticPage->picture_title = null;
$staticPage->content = "le texte par défaut des produits";
$staticPage->data = [];
$staticPage->saveQuietly();
// PRODUCT.
$staticPage = new StaticPage();
$staticPage->type = StaticPageType::product;
$staticPage->seo_title = "Seo title pour la page d'un Produit";
$staticPage->seo_description = sprintf("Seo description pour la page Produit du site %s", config('app.name'));
$staticPage->title = "Produit";
$staticPage->subtitle = "Sous-titre";
$staticPage->slug = "product";
$staticPage->picture = null;
$staticPage->picture_alt = null;
$staticPage->picture_title = null;
$staticPage->content = null;
$staticPage->data = [
"claim_title" => [
"label" => "Titre des allégations",
"inputType" => InputType::string->value,
"value" => "le titre des allégations",
"validate" => "required|string|between:3,255",
'required' => true
],
"products_title" => [
"label" => "Titre des produits",
"inputType" => InputType::string->value,
"value" => "le titre des autres produits",
"validate" => "required|string|between:3,255",
'required' => true
],
"products_text" => [
"label" => "Texte des produits",
"inputType" => InputType::text->value,
"value" => "le texte des autres produits",
"validate" => 'required|string',
'required' => true
],
"animation_text_1" => [
"label" => "Texte de l'animation 1",
"inputType" => InputType::string->value,
"value" => "le texte de l'animation 1",
"validate" => "required|string|between:3,255",
'required' => true
],
"animation_text_2" => [
"label" => "Texte de l'animation 2",
"inputType" => InputType::string->value,
"value" => "le texte de l'animation 2",
"validate" => "required|string|between:3,255",
'required' => true
],
"recipes_title" => [
"label" => "Titre des recettes",
"inputType" => InputType::string->value,
"value" => "le titre des recettes",
"validate" => "required|string|between:3,255",
'required' => true
],
"recipes_text" => [
"label" => "Texte des recettes",
"inputType" => InputType::text->value,
"value" => "le texte des recettes",
"validate" => 'required|string',
'required' => true
],
];
$staticPage->saveQuietly();
// HOME.
$staticPage = new StaticPage();
$staticPage->type = StaticPageType::home;
$staticPage->seo_title = "Seo title pour la page Accueil";
$staticPage->seo_description = sprintf(
"Seo description pour la page Accueil du site %s",
config('app.name')
);
$staticPage->title = "Accueil";
$staticPage->subtitle = null;
$staticPage->slug = "Accueil";
$staticPage->picture = null;
$staticPage->picture_alt = null;
$staticPage->picture_title = null;
$staticPage->content = null;
$staticPage->data = [];
$staticPage->saveQuietly();
DB::table('general_settings')->where('type', 3)->delete();
DB::table('general_settings')->where('type', 4)->delete();
DB::table('general_settings')->where('type', 5)->delete();
DB::table('general_settings')->where('type', 6)->delete();
}
/**
* Reverse the migrations.
*
* @return void
* @throws \Error Wont undo that.
*/
public function down(): void
{
throw new \Error('Wont undo that');
}
};

View file

@ -1,55 +0,0 @@
<?php
use App\Models\Product;
use App\Models\Recipe;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('products', function (Blueprint $table) {
$table->string('seo_title')->nullable()->comment('Product seo title.')->after('id');
$table->string('seo_description')->nullable()->comment('Product seo description.')->after('seo_title');
});
Schema::table('recipes', function (Blueprint $table) {
$table->string('seo_title')->nullable()->comment('Recipe seo title.')->after('id');
$table->string('seo_description')->nullable()->comment('Recipe seo description.')->after('seo_title');
});
Product::query()->get()->map(function (Product $productModel) {
$productModel->seo_title = sprintf("Titre SEO de la page du produit %s", $productModel->label);
$productModel->seo_description = sprintf("Description SEO de la page du produit %s", $productModel->label);
$productModel->saveQuietly();
});
Recipe::query()->get()->map(function (Recipe $recipeModel) {
$recipeModel->seo_title = sprintf("Titre SEO de la page de la recette %s", $recipeModel->title);
$recipeModel->seo_description = sprintf("Description SEO de la page de la recette %s", $recipeModel->title);
$recipeModel->saveQuietly();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('seo_title');
$table->dropColumn('seo_description');
});
Schema::table('recipes', function (Blueprint $table) {
$table->dropColumn('seo_title');
$table->dropColumn('seo_description');
});
}
};

View file

@ -1,40 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('offers', function (Blueprint $table) {
$table->id();
$table->string('title')->comment('Offer title.');
$table->string('location')->comment('Offer location.');
$table->string('contract')->comment('Offer contract.');
$table->string('function')->comment('Offer function.');
$table->string('picture')->comment('Offer picture.');
$table->string('picture_alt')->comment('Picture alt attribute.');
$table->string('picture_title')->comment('Picture title attribute.');
$table->text('description')->comment('Offer description.');
$table->boolean('published')->comment('Offer publish status.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('offers');
}
};

View file

@ -1,41 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('testimonials', function (Blueprint $table) {
$table->id();
$table->string('catchline')->comment('Testimonial catchline');
$table->text('content')->comment('Testimonial content');
$table->string('identity')->comment('Identity of the person');
$table->string('job')->comment('Job of the person');
$table->string('picture')->comment('Path of the picture of the testimonial (550x315)');
$table->string('picture_alt')->comment('Alt attribute of the picture');
$table->string('picture_title')->comment('Title attribute of the picture');
$table->string('video_id')->nullable()->comment('Id of the video to display (youtube)');
$table->integer('order')->comment('Testimonial order.');
$table->boolean('published')->comment('Testimonial publish status.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('testimonials');
}
};

View file

@ -1,40 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('news_corporates', function (Blueprint $table) {
$table->id();
$table->string('title')->comment('The title of the news corporate.');
$table->string('content')->comment('The content of the news corporate.');
$table->string('url')->nullable()->comment('Linkedin url link.');
$table->string('picture')->comment('Picture path.');
$table->string('picture_alt')->comment('Picture alt attribute.');
$table->string('picture_title')->comment('Picture title attribute.');
$table->boolean('published')->comment('News corporate publish status.');
$table->timestamp('publish_at')->nullable()->comment('News corporate publishment date.');
$table->timestamp('unpublish_at')->nullable()->comment('News corporate unpublishment date.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('news_corporates');
}
};

View file

@ -1,53 +0,0 @@
<?php
use App\Enums\StaticPageType;
use App\Models\StaticPage;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Str;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
$enumTypeArr = [StaticPageType::selling, StaticPageType::accessibility];
foreach ($enumTypeArr as $enumType) {
$staticPage = new StaticPage();
$staticPage->type = $enumType;
$staticPage->seo_title = trans(
'SEO title pour la page :label',
['label' => $enumType->label()]
);
$staticPage->seo_description = trans(
'SEO description pour la page :label',
['label' => $enumType->label()]
);
$staticPage->title = trans($enumType->label());
$staticPage->slug = Str::of($enumType->label())->slug();
$staticPage->subtitle = null;
$staticPage->picture = null;
$staticPage->picture_alt = null;
$staticPage->picture_title = null;
$staticPage->content = trans('Le contenu de votre page');
$staticPage->data = [];
$staticPage->saveQuietly();
}//end foreach
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
$enumTypeArr = [StaticPageType::selling, StaticPageType::accessibility];
foreach ($enumTypeArr as $type) {
StaticPage::query()->where('type', $type)->first()->delete();
}
}
};

View file

@ -1,33 +0,0 @@
<?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::create('news_categories', function (Blueprint $table) {
$table->id();
$table->string('seo_title')->comment('The seo title of the news category.');
$table->string('seo_description')->comment('The seo description of the news category.');
$table->string('title')->comment('News category title.');
$table->string('slug')->unique()->comment('News category title slug.');
$table->integer('order')->comment('News category order.');
$table->boolean('published')->comment('News category publish status.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('news_categories');
}
};

View file

@ -1,45 +0,0 @@
<?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::create('news', function (Blueprint $table) {
$table->id();
$table->string('seo_title')->comment('The seo title of the news.');
$table->string('seo_description')->comment('The seo description of the news.');
$table->string('title')->comment('The title of the news.');
$table->string('subtitle')->nullable()->comment('The subtitle of the news.');
$table->string('picture')->comment('Picture path.');
$table->string('picture_alt')->comment('Picture alt attribute.');
$table->string('picture_title')->comment('Picture title attribute.');
$table->string('thumbnail')->comment('Thumbnail path.');
$table->string('thumbnail_alt')->comment('Thumbnail alt attribute.');
$table->string('thumbnail_title')->comment('Thumbnail title attribute.');
$table->string('slug')->unique()->comment('Unique title slug');
$table->text('content')->comment('The content of the news.');
$table->foreignId('news_category_id')->constrained('news_categories')
->restrictOnDelete()->comment('News category id');
$table->boolean('highlight')->comment('News highlight status.');
$table->boolean('published')->comment('News publish status.');
$table->timestamp('publish_at')->nullable()->comment('News publishment date.');
$table->timestamp('unpublish_at')->nullable()->comment('News unpublishment date.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('news');
}
};

View file

@ -1,53 +0,0 @@
<?php
use App\Enums\StaticPageType;
use App\Models\StaticPage;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Str;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
$enumTypeArr = [StaticPageType::news, StaticPageType::social];
foreach ($enumTypeArr as $enumType) {
$staticPage = new StaticPage();
$staticPage->type = $enumType;
$staticPage->seo_title = trans(
'SEO title pour la page :label',
['label' => $enumType->label()]
);
$staticPage->seo_description = trans(
'SEO description pour la page :label',
['label' => $enumType->label()]
);
$staticPage->title = trans($enumType->label());
$staticPage->slug = Str::of($enumType->label())->slug();
$staticPage->subtitle = null;
$staticPage->picture = null;
$staticPage->picture_alt = null;
$staticPage->picture_title = null;
$staticPage->content = trans('Le contenu de votre page');
$staticPage->data = [];
$staticPage->saveQuietly();
}//end foreach
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
$enumTypeArr = [StaticPageType::news, StaticPageType::social];
foreach ($enumTypeArr as $type) {
StaticPage::query()->where('type', $type)->first()->delete();
}
}
};

View file

@ -1,26 +0,0 @@
<?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('videos', function (Blueprint $table) {
$table->unsignedBigInteger('product_id')->nullable()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Can't revert because some videos will have a null value in product_id foreign key.
}
};

View file

@ -1,36 +0,0 @@
<?php
use App\Models\Product;
use App\Models\Submeat;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* This one was needed because some submeats have been deleted but products still have old submeat ids.
*/
public function up(): void
{
$productModels = Product::query()->with('submeat')->get();
$actualSubmeatModelsIds = Submeat::query()->pluck('id');
foreach ($productModels as $productModel) {
if ($actualSubmeatModelsIds->doesntContain($productModel->submeat_id)) {
$productModel->submeat()->associate($actualSubmeatModelsIds->first());
$productModel->save();
}
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Can't be reverted because old ids don't exist.
}
};

View file

@ -1,74 +0,0 @@
<?php
use App\Enums\Department;
use App\Models\Breeder;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('breeders', function (Blueprint $table) {
// Rename some columns.
$table->renameColumn('inuavs', 'inuav_codes')->comment('Array of inuav codes');
$table->renameColumn('status', 'published');
// Add some columns.
$table->string('picture_alt')->nullable()->comment('Picture alt attribute.')->after('picture');
$table->string('picture_title')->nullable()->comment('Picture title attribute.')->after('picture_alt');
$table->string('department', 3)->comment('Breeder department - enum')->after('postal_code');
$table->string('approaches')->comment('Array of associated approches')->after('picture3');
$table->unsignedInteger('order')->comment('Breeder order')->after('approaches');
$table->boolean('is_highlighted')->comment('Is the breeder highlighted ? (visible in carousel)')->after('published');
});
$breederModels = Breeder::query()->get();
foreach ($breederModels as $breederModel) {
$breederModel->department = Department::make(Str::take($breederModel->postal_code, 2));
$breederModel->picture_alt = trans('Photo de :first_name :last_name', [
'first_name' => $breederModel->first_name,
'last_name' => $breederModel->last_name,
]);
$breederModel->picture_title = trans('Photo de :first_name :last_name', [
'first_name' => $breederModel->first_name,
'last_name' => $breederModel->last_name,
]);
$breederModel->approaches = [];
$breederModel->order = $breederModel->id;
$breederModel->is_highlighted = $breederModel->published;
$breederModel->save();
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('breeders', function (Blueprint $table) {
// Rename some columns.
$table->renameColumn('inuav_codes', 'inuavs')->comment('Array of inuav codes');
$table->renameColumn('published', 'status');
// Remove some columns.
$table->dropColumn('picture_alt');
$table->dropColumn('picture_title');
$table->dropColumn('department');
$table->dropColumn('approaches');
$table->dropColumn('order');
$table->dropColumn('is_highlighted');
});
}
};

View file

@ -1,45 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('news_breedings', function (Blueprint $table) {
$table->id();
$table->string('seo_title')->comment('The seo title of the news breeding.');
$table->string('seo_description')->comment('The seo description of the news breeding.');
$table->string('title')->comment('The title of the news breeding.');
$table->string('subtitle')->nullable()->comment('The title of the news breeding.');
$table->string('picture')->comment('Picture path.');
$table->string('picture_alt')->comment('Picture alt attribute.');
$table->string('picture_title')->comment('Picture title attribute.');
$table->string('slug')->comment('Unique title slug');
$table->text('content')->comment('The content of the news breeding.');
$table->unsignedTinyInteger('associated_page')->comment('Associated Page (StaticPageEnum)');
$table->integer('order')->comment('News breeding order');
$table->boolean('published')->comment('News breeding publish status.');
$table->timestamp('publish_at')->nullable()->comment('News breeding publishment date.');
$table->timestamp('unpublish_at')->nullable()->comment('News breeding unpublishment date.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('news_breedings');
}
};

View file

@ -1,63 +0,0 @@
<?php
use App\Enums\StaticPageType;
use App\Lib\Helpers\FileStorageHelper;
use App\Models\StaticPage;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Str;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
$enumTypeArr = StaticPageType::getBreedingPages();
foreach ($enumTypeArr as $enumType) {
$staticPageQuery = StaticPage::query()->where('type', $enumType);
$staticPage = $staticPageQuery->exists() ? $staticPageQuery->first() : new StaticPage();
$staticPage->type = $enumType;
$staticPage->seo_title = trans(
'SEO title pour la page :label',
['label' => $enumType->label()]
);
$staticPage->seo_description = trans(
'SEO description pour la page :label',
['label' => $enumType->label()]
);
$staticPage->title = trans($enumType->label());
$staticPage->slug = Str::of($enumType->label())->slug();
$staticPage->subtitle = fake()->sentence();
$staticPage->picture = FileStorageHelper::storeFile(
new StaticPage(),
new \SplFileInfo(
\resource_path('../database/factories/assets/static_pages/default-picture-720x405.jpg')
)
);
$staticPage->picture_alt = null;
$staticPage->picture_title = null;
$staticPage->content = trans('Le contenu de votre page');
$staticPage->data = [];
$staticPage->saveQuietly();
} //end foreach
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
$enumTypeArr = StaticPageType::getBreedingPages();
foreach ($enumTypeArr as $type) {
$query = StaticPage::query()->where('type', $type);
if ($query->exists()) {
$query->first()->deleteQuietly();
}
}
}
};

View file

@ -1,28 +0,0 @@
<?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::create('customerables', function (Blueprint $table) {
$table->foreignId('customer_id')->comment('The customer to associate.')->constrained()
->onUpdate('no action')->onDelete('cascade');
$table->morphs('customerable');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('customerables');
}
};

View file

@ -1,33 +0,0 @@
<?php
use App\Enums\Settings\SettingsType;
use App\Models\GeneralSetting;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
GeneralSetting::query()->insert([
'type' => SettingsType::breederMap,
'value' => json_encode(GeneralSetting::getJsonLayout(SettingsType::breederMap)),
'created_at' => now(),
'updated_at' => now()
]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
GeneralSetting::query()->where('type', SettingsType::breederMap)->firstOrFail()->deleteQuietly();
}
};

View file

@ -1,65 +0,0 @@
<?php
use App\Enums\Settings\MenuNodeType;
use App\Enums\Settings\SettingsType;
use App\Lib\Link;
use App\Models\GeneralSetting;
use Database\Seeders\Mandatory\GeneralSettingSeeder;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Artisan;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
* @throws \Exception In general settings menu is missing.
*/
public function up(): void
{
/** @var \App\Models\GeneralSetting|null */
$generalSettingModel = GeneralSetting::query()->where('type', SettingsType::mainMenu)->first();
if (!$generalSettingModel) {
throw new \Exception('Missing generalSettings ' . SettingsType::mainMenu->label());
}
$generalSettingModel->value = collect($generalSettingModel->value)->map(function (\stdClass $item) {
if ($item->type->equals(MenuNodeType::ourCommitments)) {
$item->link = (new Link(routeName: MenuNodeType::ourCommitments->routeName()))->toArray();
} elseif ($item->type->equals(MenuNodeType::siteLogo)) {
$item->link = (new Link(routeName: MenuNodeType::siteLogo->routeName()))->toArray();
} elseif ($item->type->equals(MenuNodeType::breedings)) {
$item->link = (new Link(routeName: MenuNodeType::breedings->routeName()))->toArray();
} elseif ($item->type->equals(MenuNodeType::ourBrand)) {
$item->link = (new Link(routeName: MenuNodeType::ourBrand->routeName()))->toArray();
} elseif ($item->type->equals(MenuNodeType::news)) {
$item->link = (new Link(routeName: MenuNodeType::news->routeName()))->toArray();
}
return $item;
});
$generalSettingModel->saveQuietly();
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
$generalSettingModel = GeneralSetting::query()->where('type', SettingsType::mainMenu)->first();
$generalSettingModel->value = collect($generalSettingModel->value)->map(function ($item) {
if (
$item->type->equals(MenuNodeType::ourCommitments)
|| $item->type->equals(MenuNodeType::siteLogo)
|| $item->type->equals(MenuNodeType::breedings)
|| $item->type->equals(MenuNodeType::ourBrand)
|| $item->type->equals(MenuNodeType::news)
) {
$item->link = (new Link(routeName: 'fo.contact.show'))->toArray();
}
return $item;
});
$generalSettingModel->saveQuietly();
}
};

View file

@ -1,30 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
* @return void
*/
public function up(): void
{
Schema::table('recipes', function (Blueprint $table) {
$table->string('tips')->nullable()->change();
});
}
/**
* Reverse the migrations.
* @return void
*/
public function down(): void
{
Schema::table('recipes', function (Blueprint $table) {
$table->string('tips')->nullable(false)->change();
});
}
};

View file

@ -1,28 +0,0 @@
<?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('recipes', function (Blueprint $table) {
$table->string('advice')->nullable()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('recipes', function (Blueprint $table) {
$table->string('advice')->nullable(false)->change();
});
}
};

View file

@ -1,36 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('products', function (Blueprint $table) {
$table->string('banner')->nullable()->change();
$table->string('banner_alt')->nullable()->change();
$table->string('banner_title')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('products', function (Blueprint $table) {
$table->string('banner')->nullable(false)->change();
$table->string('banner_alt')->nullable(false)->change();
$table->string('banner_title')->nullable(false)->change();
});
}
};

View file

@ -1,36 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('email_verified_at');
$table->dropColumn('password');
$table->date('last_connection')->nullable()->after('role');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->timestamp('email_verified_at')->nullable()->after('email');
$table->string('password')->after('email_verified_at');
$table->dropColumn('last_connection');
});
}
};

View file

@ -1,28 +0,0 @@
<?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('recipes', function (Blueprint $table) {
$table->unsignedSmallInteger('cooking_time')->nullable()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('recipes', function (Blueprint $table) {
$table->unsignedSmallInteger('cooking_time')->nullable(false)->change();
});
}
};

View file

@ -1,23 +0,0 @@
<?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('recipes', function (Blueprint $table) {
$table->string('tips', 500)->comment('Recipe tips.')->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void {}
};

View file

@ -1,36 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('products', function (Blueprint $table) {
$table->string('picture')->nullable()->change();
$table->string('picture_alt')->nullable()->change();
$table->string('picture_title')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('products', function (Blueprint $table) {
$table->string('picture')->nullable(false)->change();
$table->string('picture_alt')->nullable(false)->change();
$table->string('picture_title')->nullable(false)->change();
});
}
};

View file

@ -1,30 +0,0 @@
<?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('historical_milestones', function (Blueprint $table) {
$table->string('picto_placement')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('historical_milestones', function (Blueprint $table) {
$table->dropColumn('picto_placement');
});
}
};

View file

@ -1,45 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('historical_milestones', function (Blueprint $table) {
$table->integer('order')->comment('Milestone order.');
});
$this->setOrderForExistingMilestones();
}
private function setOrderForExistingMilestones(): void
{
// Récupérer tous les milestones actuels
$milestones = DB::table('historical_milestones')->orderBy('id')->get();
// Mettre à jour chaque milestone avec un ordre basé sur l'index
foreach ($milestones as $index => $milestone) {
DB::table('historical_milestones')
->where('id', $milestone->id)
->update(['order' => $index + 1]); // L'index commence à 0, donc +1 pour commencer à 1
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('historical_milestones', function (Blueprint $table) {
$table->dropColumn('order');
});
}
};

View file

@ -1,28 +0,0 @@
<?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('key_numbers', function (Blueprint $table) {
$table->string('source')->nullable()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('key_numbers', function (Blueprint $table) {
$table->string('source')->nullable(false)->change();
});
}
};

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('customers', function (Blueprint $table) {
$table->string('hashcode')->after('email')->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('customers', function (Blueprint $table) {
$table->string('email')->after('hashcode')->change();
});
}
};

View file

@ -1,128 +0,0 @@
<?php
use App\Enums\InputType;
use App\Enums\StaticPageType;
use App\Models\StaticPage;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
// PRODUCT.
$staticPage = StaticPage::query()->where('type', StaticPageType::product)->first();
$staticPage->data = [
"products_title" => [
"label" => "Titre des produits",
"inputType" => InputType::string->value,
"value" => "le titre des autres produits",
"validate" => "required|string|between:3,255",
'required' => true
],
"products_text" => [
"label" => "Texte des produits",
"inputType" => InputType::text->value,
"value" => "le texte des autres produits",
"validate" => 'required|string',
'required' => true
],
"animation_text_1" => [
"label" => "Texte de l'animation 1",
"inputType" => InputType::string->value,
"value" => "le texte de l'animation 1",
"validate" => "required|string|between:3,255",
'required' => true
],
"animation_text_2" => [
"label" => "Texte de l'animation 2",
"inputType" => InputType::string->value,
"value" => "le texte de l'animation 2",
"validate" => "required|string|between:3,255",
'required' => true
],
"recipes_title" => [
"label" => "Titre des recettes",
"inputType" => InputType::string->value,
"value" => "le titre des recettes",
"validate" => "required|string|between:3,255",
'required' => true
],
"recipes_text" => [
"label" => "Texte des recettes",
"inputType" => InputType::text->value,
"value" => "le texte des recettes",
"validate" => 'required|string',
'required' => true
],
];
$staticPage->saveQuietly();
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
// PRODUCT.
$staticPage = StaticPage::query()->where('type', StaticPageType::product)->first();
$staticPage->data = [
"claim_title" => [
"label" => "Titre des allégations",
"inputType" => InputType::string->value,
"value" => "le titre des allégations",
"validate" => "required|string|between:3,255",
'required' => true
],
"products_title" => [
"label" => "Titre des produits",
"inputType" => InputType::string->value,
"value" => "le titre des autres produits",
"validate" => "required|string|between:3,255",
'required' => true
],
"products_text" => [
"label" => "Texte des produits",
"inputType" => InputType::text->value,
"value" => "le texte des autres produits",
"validate" => 'required|string',
'required' => true
],
"animation_text_1" => [
"label" => "Texte de l'animation 1",
"inputType" => InputType::string->value,
"value" => "le texte de l'animation 1",
"validate" => "required|string|between:3,255",
'required' => true
],
"animation_text_2" => [
"label" => "Texte de l'animation 2",
"inputType" => InputType::string->value,
"value" => "le texte de l'animation 2",
"validate" => "required|string|between:3,255",
'required' => true
],
"recipes_title" => [
"label" => "Titre des recettes",
"inputType" => InputType::string->value,
"value" => "le titre des recettes",
"validate" => "required|string|between:3,255",
'required' => true
],
"recipes_text" => [
"label" => "Texte des recettes",
"inputType" => InputType::text->value,
"value" => "le texte des recettes",
"validate" => 'required|string',
'required' => true
],
];
$staticPage->saveQuietly();
}
};

View file

@ -1,28 +0,0 @@
<?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('products', function (Blueprint $table) {
$table->string('claim_title')->nullable()->comment('The claim title for a product.')->after('label');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('claim_title');
});
}
};

View file

@ -1,30 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
* @return void
*/
public function up(): void
{
Schema::table('recipes', function (Blueprint $table) {
$table->string('tips', 500)->nullable()->change();
});
}
/**
* Reverse the migrations.
* @return void
*/
public function down(): void
{
Schema::table('recipes', function (Blueprint $table) {
$table->string('tips', 500)->nullable(false)->change();
});
}
};

View file

@ -1,34 +0,0 @@
<?php
use App\Models\NewsCategory;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('news_categories', function (Blueprint $table) {
$table->unsignedBigInteger('color')->after('slug')->comment('News associated color.');
});
NewsCategory::query()->get()->map(function (NewsCategory $category) {
$category->color = fake()->unique()->safeHexColor();
$category->saveQuietly();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('news_categories', function (Blueprint $table) {
$table->dropColumn('color');
});
}
};

View file

@ -1,48 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
// @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
class CreateDepartaimantsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('departaimants', function (Blueprint $table) {
$table->id();
$table->smallInteger('type')->unsigned();
/**
* bigInt = 8 octets (64bits)
* Donc à raison de 2 colonnes par départements
* on peut en stocker 32 dans un big int
* Il existe 101 départements Français
* Donc il faut 32*4 = 128
* au moins 4 colonnes
*/
$table->bigInteger('col1')->unsigned()->default(0);
$table->bigInteger('col2')->unsigned()->default(0);
$table->bigInteger('col3')->unsigned()->default(0);
$table->bigInteger('col4')->unsigned()->default(0);
$table->foreignId('customer_id');
$table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade');
$table->timestamps();
$table->unique(['type', 'customer_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('departaimants');
}
}

View file

@ -1,39 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
class CreateMessagesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('messages', function (Blueprint $table) {
$table->id();
$table->string('message', 255);
$table->boolean('hide_from')->default(false);
$table->boolean('hide_to')->default(false);
$table->foreignId('from')->nullable();
$table->foreign('from')->references('id')->on('customers')->cascadeOnDelete();
$table->foreignId('to')->nullable();
$table->foreign('to')->references('id')->on('customers')->cascadeOnDelete();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('messages');
}
}

View file

@ -1,36 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
class CreateBlockListsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('block_lists', function (Blueprint $table) {
$table->id();
$table->foreignId('customer_id')->nullable();
$table->foreign('customer_id')->references('id')->on('customers')->cascadeOnDelete();
$table->foreignId('blocked_id')->nullable();
$table->foreign('blocked_id')->references('id')->on('customers')->cascadeOnDelete();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('block_lists');
}
}

View file

@ -1,35 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
// @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
class CreateNotifications extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->id();
$table->tinyInteger('type');
$table->morphs('notifiable');
$table->string('content');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('notifications');
}
}

View file

@ -1,33 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
// @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
class CreateNotificationsRead extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('notifications_read', function (Blueprint $table) {
$table->foreignId('notification_id')->constrained('notifications')->onDelete('cascade');
$table->foreignId('customer_id')->constrained('customers');
$table->primary(['notification_id', 'customer_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('notifications_read');
}
}

View file

@ -1,35 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
class AddCustomerIdToNotificationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('notifications', function (Blueprint $table) {
$table->foreignId('customer_id')->nullable()->after('content');
$table->foreign('customer_id')->references('id')->on('customers')->cascadeOnDelete();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('notifications', function (Blueprint $table) {
$table->dropForeign(['customer_id']);
$table->dropColumn(['customer_id']);
});
}
}

View file

@ -1,90 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('products', function (Blueprint $table) {
$table->dropForeign(['approach_id']);
$table->dropForeign(['meat_id']);
$table->dropForeign(['submeat_id']);
$table->dropForeign(['range_id']);
$table->dropForeign(['subrange_id']);
$table->foreign('approach_id')
->references('id')
->on('approaches')
->onUpdate('SET NULL')
->onDelete('SET NULL');
$table->foreign('meat_id')
->references('id')
->on('meats')
->onUpdate('SET NULL')
->onDelete('SET NULL');
$table->foreign('submeat_id')
->references('id')
->on('submeats')
->onUpdate('SET NULL')
->onDelete('SET NULL');
$table->foreign('range_id')
->references('id')
->on('ranges')
->onUpdate('SET NULL')
->onDelete('SET NULL');
$table->foreign('subrange_id')
->references('id')
->on('subranges')
->onUpdate('SET NULL')
->onDelete('SET NULL');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('products', function (Blueprint $table) {
$table->dropForeign(['approach_id']);
$table->dropForeign(['meat_id']);
$table->dropForeign(['submeat_id']);
$table->dropForeign(['range_id']);
$table->dropForeign(['subrange_id']);
$table->foreign('approach_id')
->references('id')
->on('approaches')
->onUpdate('CASCADE')
->onDelete('CASCADE');
$table->foreign('meat_id')
->references('id')
->on('meats')
->onUpdate('CASCADE')
->onDelete('CASCADE');
$table->foreign('submeat_id')
->references('id')
->on('submeats')
->onUpdate('CASCADE')
->onDelete('CASCADE');
$table->foreign('range_id')
->references('id')
->on('ranges')
->onUpdate('CASCADE')
->onDelete('CASCADE');
$table->foreign('subrange_id')
->references('id')
->on('subranges')
->onUpdate('CASCADE')
->onDelete('CASCADE');
});
}
};

View file

@ -1,109 +0,0 @@
<?php
use App\Enums\InputType;
use App\Enums\StaticPageType;
use App\Models\StaticPage;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
// RECRUITMENT.
$staticPage = StaticPage::query()->where('type', StaticPageType::recruitment)->first();
$staticPage->data = [
"offers_title" => [
"label" => "Titre des offres",
"inputType" => InputType::string->value,
"value" => "le titre des offres",
"validate" => "required|string|between:3,255",
'required' => true
],
"offers_description" => [
"label" => "Description des offres",
"inputType" => InputType::text->value,
"value" => "la description des offres",
"validate" => "required|string|min:15",
'required' => true
],
"jobs_title" => [
"label" => "Titre des métiers",
"inputType" => InputType::string->value,
"value" => "le titre des métiers",
"validate" => "required|string|between:3,255",
'required' => true
],
"jobs_description" => [
"label" => "Description des métiers",
"inputType" => InputType::text->value,
"value" => "la description des métiers",
"validate" => "required|string|min:15",
'required' => true
],
"testimonies_title" => [
"label" => "Titre des témoignages",
"inputType" => InputType::string->value,
"value" => "le titre des témoignages",
"validate" => "required|string|between:3,255",
'required' => true
],
"testimonies_description" => [
"label" => "Description des témoignages",
"inputType" => InputType::text->value,
"value" => "la description des témoignages",
"validate" => "required|string|min:15",
'required' => true
],
"advantages_title" => [
"label" => "Titre des avantages",
"inputType" => InputType::string->value,
"value" => "le titre des avantages",
"validate" => "required|string|between:3,255",
'required' => true
],
"advantages_description" => [
"label" => "Description des avantages",
"inputType" => InputType::text->value,
"value" => "la description des avantages",
"validate" => "required|string|min:15",
'required' => true
],
"actualities_title" => [
"label" => "Titre des actualités",
"inputType" => InputType::string->value,
"value" => "le titre des actualités",
"validate" => "required|string|between:3,255",
'required' => true
],
"actualities_description" => [
"label" => "Description des actualités",
"inputType" => InputType::text->value,
"value" => "la description des actualités",
"validate" => "required|string|min:15",
'required' => true
],
];
$staticPage->saveQuietly();
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('static_pages', function () {
// RECRUITMENT.
$staticPage = StaticPage::query()->where('type', StaticPageType::recruitment)->first();
$staticPage->data = [];
$staticPage->saveQuietly();
});
}
};

View file

@ -1,38 +0,0 @@
<?php
use App\Models\Offer;
use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('offers', function (Blueprint $table) {
$table->timestamp('publish_at')->comment('Slide publishment date.')->after('published');
});
Offer::query()->get()->map(function (Offer $offer) {
$offer->publish_at = Carbon::now();
$offer->saveQuietly();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('offers', function (Blueprint $table) {
$table->dropColumn('publish_at');
});
}
};

View file

@ -1,33 +0,0 @@
<?php
use App\Enums\Settings\SettingsType;
use App\Models\GeneralSetting;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
GeneralSetting::query()->insert([
'type' => SettingsType::offersCount,
'value' => json_encode(GeneralSetting::getJsonLayout(SettingsType::offersCount)),
'created_at' => now(),
'updated_at' => now()
]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
GeneralSetting::query()->where('type', SettingsType::offersCount)->firstOrFail()->deleteQuietly();
}
};

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('offers', function (Blueprint $table) {
$table->string('link')->comment('Offer link.')->after('picture_title');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('offers', function (Blueprint $table) {
$table->dropColumn('link');
});
}
};

View file

@ -1,70 +0,0 @@
<?php
use App\Enums\InputType;
use App\Enums\StaticPageType;
use App\Models\StaticPage;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
// STORY.
$staticPage = StaticPage::query()->where('type', StaticPageType::story)->first();
$staticPage->data = [
"image" => [
'label' => 'Image',
"inputType" => InputType::image->value,
'dimensions' => ['width' => 1280, 'height' => 720],
'alt' => "Image attribut alt",
'title' => "Image attribut titre",
'value' => "",
'validate' => 'required',
'required' => true
],
"link" => [
"label" => "Lien",
"inputType" => InputType::url->value,
"value" => "https://google.com",
"validate" => "required|string|url:http,https",
'required' => true
],
"link_label" => [
"label" => "Label du lien",
"inputType" => InputType::string->value,
"value" => "Label du bouton",
"validate" => "required|string|between:3,255",
'required' => true
],
"link_new_tab" => [
"label" => "Ouverture du lien dans un nouvel onglet",
"inputType" => InputType::boolean->value,
"value" => true,
"validate" => "required|boolean",
'required' => true
],
];
$staticPage->saveQuietly();
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('static_pages', function () {
// STORY.
$staticPage = StaticPage::query()->where('type', StaticPageType::story)->first();
$staticPage->data = [];
$staticPage->saveQuietly();
});
}
};

View file

@ -1,47 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
$messages = DB::table('messages')->get();
Schema::table('messages', function (Blueprint $table) {
$table->text('message')->change();
});
$messages->each(function (object $message) {
DB::table('messages')->where('id', $message->id)->update([
'message' => Crypt::encryptString($message->message)
]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
$messages = DB::table('messages')->get();
$messages->each(function (object $message) {
DB::table('messages')->where('id', $message->id)->update([
'message' => Str::limit(Crypt::decryptString($message->message), 255)
]);
});
Schema::table('messages', function (Blueprint $table) {
$table->string('message')->change();
});
}
};

View file

@ -1,130 +0,0 @@
<?php
use App\Enums\InputType;
use App\Enums\StaticPageType;
use App\Models\StaticPage;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
// STORY.
$staticPage = StaticPage::query()->where('type', StaticPageType::story)->first();
$staticPage->data = [
"image" => [
'label' => 'Image',
"inputType" => InputType::image->value,
'dimensions' => ['width' => 1280, 'height' => 720],
'alt' => "Image attribut alt",
'title' => "Image attribut titre",
'value' => "",
'validate' => 'required',
'required' => true
],
"link" => [
"label" => "Lien",
"inputType" => InputType::url->value,
"value" => "https://google.com",
"validate" => "required|string|url:http,https",
'required' => true
],
"link_label" => [
"label" => "Label du lien",
"inputType" => InputType::string->value,
"value" => "Label du bouton",
"validate" => "required|string|between:3,255",
'required' => true
],
"link_new_tab" => [
"label" => "Ouverture du lien dans un nouvel onglet",
"inputType" => InputType::boolean->value,
"value" => true,
"validate" => "required|boolean",
'required' => true
],
"keynumbers_title" => [
"label" => "Titre des chiffres clés",
"inputType" => InputType::string->value,
"value" => "le titre des chiffres clés",
"validate" => "required|string|between:3,255",
'required' => true
],
"keynumbers_description" => [
"label" => "Description des chiffres clés",
"inputType" => InputType::text->value,
"value" => "la description des chiffres clés",
"validate" => "required|string|min:15",
'required' => true
],
"story_title" => [
"label" => "Titre de l'histoire",
"inputType" => InputType::string->value,
"value" => "le titre de l'histoire",
"validate" => "required|string|between:3,255",
'required' => true
],
"story_description" => [
"label" => "Description de l'histoire",
"inputType" => InputType::text->value,
"value" => "la description de l'histoire",
"validate" => "required|string|min:15",
'required' => true
],
];
$staticPage->saveQuietly();
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('static_pages', function () {
// STORY.
$staticPage = StaticPage::query()->where('type', StaticPageType::story)->first();
$staticPage->data = [
"image" => [
'label' => 'Image',
"inputType" => InputType::image->value,
'dimensions' => ['width' => 1280, 'height' => 720],
'alt' => "Image attribut alt",
'title' => "Image attribut titre",
'value' => "",
'validate' => 'required',
'required' => true
],
"link" => [
"label" => "Lien",
"inputType" => InputType::url->value,
"value" => "https://google.com",
"validate" => "required|string|url:http,https",
'required' => true
],
"link_label" => [
"label" => "Label du lien",
"inputType" => InputType::string->value,
"value" => "Label du bouton",
"validate" => "required|string|between:3,255",
'required' => true
],
"link_new_tab" => [
"label" => "Ouverture du lien dans un nouvel onglet",
"inputType" => InputType::boolean->value,
"value" => true,
"validate" => "required|boolean",
'required' => true
],
];
$staticPage->saveQuietly();
});
}
};

View file

@ -1,40 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('historical_milestones', function (Blueprint $table) {
$table->string('picture')->nullable()->comment('Historical milestone picture.')->change();
$table->string('picture_alt')->nullable()->comment('Picture alt attribute.')->change();
$table->string('picture_title')->nullable()->comment('Picture title attribute.')->change();
$table->string('video_id')->nullable()->comment('Historical milestone video ID.')->after('picture_title');
$table->string('picto')->nullable()->comment('Historical milestone picto.')->after('video_id');
$table->string('picto_alt')->nullable()->comment('Picture alt attribute.')->after('picto');
$table->string('picto_title')->nullable()->comment('Picture title attribute.')->after('picto_alt');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('historical_milestones', function (Blueprint $table) {
$table->dropColumn('picto');
$table->dropColumn('picto_alt');
$table->dropColumn('picto_title');
});
}
};

View file

@ -1,38 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('customers', function (Blueprint $table) {
$table->dropColumn('hashcode');
$table->dropColumn('password');
});
Schema::table('customers', function (Blueprint $table) {
$table->uuid('hashcode')->unique()->after('id')->comment('Customer unique CRM hashcode.');
$table->string('email')->comment('Customer unique email.')->change();
$table->string('username')->comment('Customer unique username.')->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('customers', function (Blueprint $table) {
$table->string('password')->comment('A enlever lors de la mise en place CRM');
});
}
};

View file

@ -1,42 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('news_clubs', function (Blueprint $table) {
$table->id();
$table->string('title')->comment('News club title.');
$table->string('slug')->unique()->comment('News club title slug.');
$table->string('picture')->comment('News club picture path.');
$table->string('picture_alt')->comment('Picture alt attribute.');
$table->string('picture_title')->comment('Picture title attribute.');
$table->text('content')->nullable()->comment('News club content.');
$table->integer('type')->comment('News club type.');
$table->boolean('multiple_answers')->comment('News club multiple answers.');
$table->boolean('published')->comment('News club publish status.');
$table->timestamp('publish_at')->nullable()->comment('News club publishment date.');
$table->timestamp('unpublish_at')->nullable()->comment('News club unpublishment date.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('news_clubs');
}
};

Some files were not shown because too many files have changed in this diff Show more