743 lines
25 KiB
PHP
743 lines
25 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\InputType;
|
|
use App\Lib\Helpers\FileStorageHelper;
|
|
use App\Lib\Helpers\ToolboxHelper;
|
|
use App\Traits\Models\ActivityLog;
|
|
use App\Traits\Models\MiniCrudModel;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @property \App\Enums\Sections\PageSectionEnum $section Slider that contains the slide.
|
|
* @property string $h2_title Title.
|
|
* @property string $text WYSIWYG - Content.
|
|
* @property string $data Minicrud content.
|
|
* @property-read \Carbon\Carbon $created_at Created date.
|
|
* @property-read \Carbon\Carbon $updated_at Updated date.
|
|
*
|
|
* @property-read \App\Models\StaticPage $page StaticPage Belongs to relationship.
|
|
* @property-read \App\Models\ActivityLog $activityLogs Activities logs One-to-many relationship.
|
|
*/
|
|
class Section extends Model
|
|
{
|
|
use ActivityLog;
|
|
use HasFactory;
|
|
use MiniCrudModel;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'section',
|
|
'h2_title',
|
|
'text',
|
|
'data',
|
|
'page_id',
|
|
'id',
|
|
'created_at',
|
|
'updated_at'
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be cast.
|
|
*
|
|
* @var array<string, string>
|
|
*/
|
|
protected $casts = [
|
|
'section' => \App\Enums\Sections\PageSectionEnum::class,
|
|
'data' => 'object',
|
|
];
|
|
|
|
/**
|
|
* Perform any actions required after the model boots.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function () {
|
|
throw new \RuntimeException("Creating a new section is not authorized");
|
|
});
|
|
static::updating(function (self $model) {
|
|
// * ASSERTIONS
|
|
ToolboxHelper::assertNoInternalBoUrls('text', $model->text);
|
|
|
|
// * TRANSFORMATIONS
|
|
$model->text = FileStorageHelper::storeModelFilesFromHtml($model, $model->text);
|
|
});
|
|
static::updated(function (self $model) {
|
|
FileStorageHelper::removeOldModelFilesFromHtml(
|
|
$model->text,
|
|
ToolboxHelper::getOriginal($model, 'text')
|
|
);
|
|
});
|
|
static::deleting(function () {
|
|
throw new \RuntimeException('Deleting a section is not authorized');
|
|
});
|
|
}
|
|
|
|
// * METHODS
|
|
|
|
/**
|
|
* Get MiniCrud bloc for home_missions section.
|
|
*
|
|
* @param array $data
|
|
* @param string $img
|
|
* @param string $imgAlt
|
|
* @param string $imgTitle
|
|
* @param integer $width
|
|
* @param integer $height
|
|
* @param string $url
|
|
* @param integer $keyValueSites
|
|
* @param integer $keyValueJobs
|
|
* @return array
|
|
*/
|
|
public static function getHomeMissionsBloc(
|
|
array $data,
|
|
string $img,
|
|
string $imgAlt,
|
|
string $imgTitle,
|
|
int $width,
|
|
int $height,
|
|
string $url,
|
|
int $keyValueSites,
|
|
int $keyValueJobs
|
|
): array {
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height);
|
|
$data = self::emptyPictureLinkBloc($data, $url);
|
|
$data = self::emptyKeyNumberBloc($data, 'sites', $keyValueSites);
|
|
$data = self::emptyKeyNumberBloc($data, 'métiers', $keyValueJobs);
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for home_ambition section.
|
|
*
|
|
* @param array $data
|
|
* @return array
|
|
*/
|
|
public static function getHomeAmbitionBloc(array $data): array
|
|
{
|
|
return self::emptyButtonBooleanBloc($data, 'On se Dévoile');
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for home_team section.
|
|
*
|
|
* @param array $data
|
|
* @param string $img
|
|
* @param string $imgAlt
|
|
* @param string $imgTitle
|
|
* @param integer $width
|
|
* @param integer $height
|
|
* @param string $url
|
|
* @return array
|
|
*/
|
|
public static function getHomeTeamBloc(
|
|
array $data,
|
|
string $img,
|
|
string $imgAlt,
|
|
string $imgTitle,
|
|
int $width,
|
|
int $height,
|
|
string $url
|
|
): array {
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height);
|
|
$data = self::emptyPictureLinkBloc($data, $url);
|
|
$data = self::emptyButtonBooleanBloc($data, 'On Embauche');
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for home_life section.
|
|
*
|
|
* @param array $data
|
|
* @return array
|
|
*/
|
|
public static function getHomeLifeBloc(array $data): array
|
|
{
|
|
return self::emptyButtonBooleanBloc($data, 'On Embauche');
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for unveil_pole section.
|
|
*
|
|
* @param array $data
|
|
* @param integer $keyValueSites
|
|
* @param integer $keyValueSpecies
|
|
* @param integer $keyValueCa
|
|
* @param integer $keyValueEmployees
|
|
* @return array
|
|
*/
|
|
public static function getUnveilPoleBloc(
|
|
array $data,
|
|
int $keyValueSites,
|
|
int $keyValueSpecies,
|
|
int $keyValueCa,
|
|
int $keyValueEmployees
|
|
): array {
|
|
$data = self::emptyKeyNumberBloc($data, 'sites', $keyValueSites);
|
|
$data = self::emptyKeyNumberBloc($data, 'espèces', $keyValueSpecies);
|
|
$data = self::emptyKeyNumberBloc($data, 'ca', $keyValueCa);
|
|
$data = self::emptyKeyNumberBloc($data, 'collaborateurs', $keyValueEmployees);
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for hire_grow section.
|
|
*
|
|
* @param array $data
|
|
* @param string $title
|
|
* @return array
|
|
*/
|
|
public static function getHireGrowBloc(array $data, string $title): array
|
|
{
|
|
return self::emptyStringBloc($data, "Titre h3 de la section", $title);
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for hire_parity section.
|
|
*
|
|
* @param array $data
|
|
* @param string $img
|
|
* @param string $imgAlt
|
|
* @param string $imgTitle
|
|
* @param integer $width
|
|
* @param integer $height
|
|
* @return array
|
|
*/
|
|
public static function getHireParityBloc(
|
|
array $data,
|
|
string $img,
|
|
string $imgAlt,
|
|
string $imgTitle,
|
|
int $width,
|
|
int $height
|
|
): array {
|
|
$data = self::emptyButtonBooleanBloc($data, 'On Bouge Ensemble');
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true);
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for commit_breeding section.
|
|
*
|
|
* @param array $data
|
|
* @param string $content
|
|
* @param string $string
|
|
* @return array
|
|
*/
|
|
public static function getCommitBreedingBloc(
|
|
array $data,
|
|
string $content,
|
|
string $string
|
|
): array {
|
|
$data = self::emptyWysiwygBloc($data, 'images', $content, \App\Enums\CkEditorConfigName::advanced);
|
|
$data = self::emptyButtonBooleanBloc($data, 'On Témoigne - engagements');
|
|
$data = self::emptyKeyNumberBloc($data, 'nombre');
|
|
$data = self::emptyWysiwygBloc($data, "text accompagnant le nombre", $string);
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for commit_living section.
|
|
*
|
|
* @param array $data
|
|
* @param string $content
|
|
* @param string $string
|
|
* @return array
|
|
*/
|
|
public static function getCommitLivingBloc(array $data, string $content, string $string): array
|
|
{
|
|
$data = self::emptyButtonBooleanBloc($data, 'On Témoigne - engagements');
|
|
$data = self::emptyWysiwygBloc($data, 'numéro 2', $content, \App\Enums\CkEditorConfigName::advanced);
|
|
$data = self::emptyButtonBooleanBloc($data, 'On Bouge');
|
|
$data = self::emptyKeyNumberBloc($data, 'nombre n°1');
|
|
$data = self::emptyWysiwygBloc($data, "text accompagnant le nombre n°1", $string);
|
|
$data = self::emptyKeyNumberBloc($data, 'nombre n°2');
|
|
$data = self::emptyWysiwygBloc($data, "text accompagnant le nombre n°2", $string);
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for commit_respect_earth section.
|
|
*
|
|
* @param array $data
|
|
* @param string $content
|
|
* @param string $img
|
|
* @param string $imgAlt
|
|
* @param string $imgTitle
|
|
* @param integer $width
|
|
* @param integer $height
|
|
* @return array
|
|
*/
|
|
public static function getCommitRespectEarthBloc(
|
|
array $data,
|
|
string $content,
|
|
string $img,
|
|
string $imgAlt,
|
|
string $imgTitle,
|
|
int $width,
|
|
int $height
|
|
): array {
|
|
$data = self::emptyKeyNumberBloc($data, 'nombre n°1');
|
|
$data = self::emptyWysiwygBloc($data, "text accompagnant le nombre n°1", $content);
|
|
$data = self::emptyKeyNumberBloc($data, 'nombre n°2');
|
|
$data = self::emptyWysiwygBloc($data, "text accompagnant le nombre n°2", $content);
|
|
$data = self::emptyButtonBooleanBloc($data, 'On Témoigne - engagements');
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height);
|
|
$data = self::emptyWysiwygBloc($data, 'numéro 2', $content, \App\Enums\CkEditorConfigName::advanced);
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for commit_feed section.
|
|
*
|
|
* @param array $data
|
|
* @param string $content
|
|
* @param string $secondContent
|
|
* @return array
|
|
*/
|
|
public static function getCommitFeedBloc(array $data, string $content, string $secondContent): array
|
|
{
|
|
$data = self::emptyKeyNumberBloc($data, 'nombre n°1');
|
|
$data = self::emptyWysiwygBloc($data, "text accompagnant le nombre n°1", $content);
|
|
$data = self::emptyKeyNumberBloc($data, 'nombre n°2');
|
|
$data = self::emptyWysiwygBloc($data, "text accompagnant le nombre n°2", $content);
|
|
$data = self::emptyButtonBooleanBloc($data, 'On Témoigne - engagements');
|
|
$data = self::emptyWysiwygBloc($data, 'numéro 2', $content, \App\Enums\CkEditorConfigName::advanced);
|
|
$data = self::emptyButtonBooleanBloc($data, 'On Produit');
|
|
$data = self::emptyWysiwygBloc($data, 'numéro 3', $secondContent, \App\Enums\CkEditorConfigName::advanced);
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for commit_commitments section.
|
|
*
|
|
* @param array $data
|
|
* @param string $firstTitle
|
|
* @param string $secondTitle
|
|
* @return array
|
|
*/
|
|
public static function getCommitCommitmentsBloc(array $data, string $firstTitle, string $secondTitle): array
|
|
{
|
|
$data = self::emptyStringBloc($data, "Titre h3 de la section numéro 1", $firstTitle);
|
|
$data = self::emptyStringBloc($data, "Titre h3 de la section numéro 2", $secondTitle);
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for move_commitments section.
|
|
*
|
|
* @param array $data
|
|
* @return array
|
|
*/
|
|
public static function getMoveCommitmentsBloc(array $data): array
|
|
{
|
|
return self::emptyButtonBooleanBloc($data, 'On Témoigne - engagements');
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for produce_local section.
|
|
*
|
|
* @param array $data
|
|
* @param string $content
|
|
* @param string $img
|
|
* @param string $imgAlt
|
|
* @param string $imgTitle
|
|
* @param integer $width
|
|
* @param integer $height
|
|
* @return array
|
|
*/
|
|
public static function getProduceLocalBloc(
|
|
array $data,
|
|
string $content,
|
|
string $img,
|
|
string $imgAlt,
|
|
string $imgTitle,
|
|
int $width,
|
|
int $height
|
|
): array {
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height);
|
|
$data = self::emptyWysiwygBloc($data, 'accompagnant l\'image', $content);
|
|
$data = self::emptyWysiwygBloc($data, 'text', $content);
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for produce_gms section.
|
|
*
|
|
* @param array $data
|
|
* @param string $content
|
|
* @param string $img
|
|
* @param string $imgAlt
|
|
* @param string $imgTitle
|
|
* @param integer $width
|
|
* @param integer $height
|
|
* @param string $banner
|
|
* @param integer $bannerWidth
|
|
* @param integer $bannerHeight
|
|
* @return array
|
|
*/
|
|
public static function getProduceGmsBloc(
|
|
array $data,
|
|
string $content,
|
|
string $img,
|
|
string $imgAlt,
|
|
string $imgTitle,
|
|
int $width,
|
|
int $height,
|
|
string $banner,
|
|
int $bannerWidth,
|
|
int $bannerHeight,
|
|
): array {
|
|
// @phpcs:disable Generic.Files.LineLength.TooLong
|
|
$data = self::emptyPictureBloc($data, $banner, $imgAlt, $imgTitle, $bannerWidth, $bannerHeight, true, "Bannière de la partie 1");
|
|
$data = self::emptyWysiwygBloc($data, 'accompagnant l\'image 1 de la partie 1', $content);
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true, "Image 1 de la partie 1");
|
|
$data = self::emptyWysiwygBloc($data, 'accompagnant l\'image 2 de la partie 1', $content);
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true, "Image 2 de la partie 1");
|
|
$data = self::emptyWysiwygBloc($data, 'accompagnant l\'image 3 de la partie 1', $content);
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true, "Image 3 de la partie 1");
|
|
$data = self::emptyWysiwygBloc($data, 'titre 2', $content);
|
|
$data = self::emptyPictureBloc($data, $banner, $imgAlt, $imgTitle, $bannerWidth, $bannerHeight, true, "Bannière de la partie 2");
|
|
$data = self::emptyWysiwygBloc($data, 'accompagnant l\'image 1 de la partie 2', $content);
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true, "Image 1 de la partie 2");
|
|
$data = self::emptyWysiwygBloc($data, 'accompagnant l\'image 2 de la partie 2', $content);
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true, "Image 2 de la partie 2");
|
|
$data = self::emptyWysiwygBloc($data, 'accompagnant l\'image 3 de la partie 2', $content);
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true, "Image 3 de la partie 2");
|
|
$data = self::emptyWysiwygBloc($data, 'titre 3', $content);
|
|
$data = self::emptyPictureBloc($data, $banner, $imgAlt, $imgTitle, $bannerWidth, $bannerHeight, true, "Bannière de la partie 3");
|
|
$data = self::emptyWysiwygBloc($data, 'accompagnant l\'image 1 de la partie 3', $content);
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true, "Image 1 de la partie 3");
|
|
// @phpcs:enable
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for produce_rhd section.
|
|
*
|
|
* @param array $data
|
|
* @param string $content
|
|
* @param string $img
|
|
* @param string $imgAlt
|
|
* @param string $imgTitle
|
|
* @param integer $width
|
|
* @param integer $height
|
|
* @param string $banner
|
|
* @param integer $bannerWidth
|
|
* @param integer $bannerHeight
|
|
* @return array
|
|
*/
|
|
public static function getProduceRhdBloc(
|
|
array $data,
|
|
string $content,
|
|
string $img,
|
|
string $imgAlt,
|
|
string $imgTitle,
|
|
int $width,
|
|
int $height,
|
|
string $banner,
|
|
int $bannerWidth,
|
|
int $bannerHeight,
|
|
): array {
|
|
// @phpcs:disable Generic.Files.LineLength.TooLong
|
|
$data = self::emptyPictureBloc($data, $banner, $imgAlt, $imgTitle, $bannerWidth, $bannerHeight, true, "Bannière de la partie 1");
|
|
$data = self::emptyWysiwygBloc($data, 'accompagnant l\'image 1 de la partie 1', $content);
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true, "Image 1 de la partie 1");
|
|
$data = self::emptyWysiwygBloc($data, 'accompagnant l\'image 2 de la partie 1', $content);
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true, "Image 2 de la partie 1");
|
|
$data = self::emptyWysiwygBloc($data, 'accompagnant l\'image 3 de la partie 1', $content);
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true, "Image 3 de la partie 1");
|
|
$data = self::emptyWysiwygBloc($data, 'accompagnant l\'image 1 de la partie 2', $content);
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true, "Image 1 de la partie 2");
|
|
// @phpcs:enable
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for produce_export section.
|
|
*
|
|
* @param array $data
|
|
* @param string $content
|
|
* @param string $img
|
|
* @param string $imgAlt
|
|
* @param string $imgTitle
|
|
* @param integer $width
|
|
* @param integer $height
|
|
* @param string $banner
|
|
* @param integer $bannerWidth
|
|
* @param integer $bannerHeight
|
|
* @return array
|
|
*/
|
|
public static function getProduceExportBloc(
|
|
array $data,
|
|
string $content,
|
|
string $img,
|
|
string $imgAlt,
|
|
string $imgTitle,
|
|
int $width,
|
|
int $height,
|
|
string $banner,
|
|
int $bannerWidth,
|
|
int $bannerHeight,
|
|
): array {
|
|
// @phpcs:disable Generic.Files.LineLength.TooLong
|
|
$data = self::emptyPictureBloc($data, $banner, $imgAlt, $imgTitle, $bannerWidth, $bannerHeight, true, "Bannière de la partie");
|
|
$data = self::emptyWysiwygBloc($data, 'accompagnant l\'image 1 de la partie', $content);
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true, "Image 1 de la partie");
|
|
$data = self::emptyWysiwygBloc($data, 'accompagnant l\'image 2 de la partie', $content);
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true, "Image 2 de la partie");
|
|
$data = self::emptyWysiwygBloc($data, 'accompagnant l\'image 3 de la partie', $content);
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true, "Image 3 de la partie");
|
|
// @phpcs:enable
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Get MiniCrud bloc for produce_quality section.
|
|
*
|
|
* @param array $data
|
|
* @param string $content
|
|
* @param string $img
|
|
* @param string $imgAlt
|
|
* @param string $imgTitle
|
|
* @param integer $width
|
|
* @param integer $height
|
|
* @param string $banner
|
|
* @param integer $bannerWidth
|
|
* @param integer $bannerHeight
|
|
* @return array
|
|
*/
|
|
public static function getProduceQualityBloc(
|
|
array $data,
|
|
string $content,
|
|
string $img,
|
|
string $imgAlt,
|
|
string $imgTitle,
|
|
int $width,
|
|
int $height,
|
|
string $banner,
|
|
int $bannerWidth,
|
|
int $bannerHeight,
|
|
): array {
|
|
// @phpcs:disable Generic.Files.LineLength.TooLong
|
|
$data = self::emptyButtonBooleanBloc($data, "'On vous explique comment lire cette étiquette'");
|
|
$data = self::emptyPictureBloc($data, $banner, $imgAlt, $imgTitle, $bannerWidth, $bannerHeight, true, "Bannière de la partie 1");
|
|
$data = self::emptyWysiwygBloc($data, "accompagnant l'image 1 de la partie 1", $content);
|
|
$data = self::emptyPictureBloc($data, $img, $imgAlt, $imgTitle, $width, $height, true, "Image 1 de la partie 1");
|
|
$data = self::emptyWysiwygBloc($data, "text de la partie 2", $content);
|
|
$data = self::emptyWysiwygBloc($data, "accompagnant le bouton 'On vous écoute'", $content);
|
|
$data = self::emptyButtonBooleanBloc($data, "'On vous écoute'");
|
|
$data = self::emptyWysiwygBloc($data, "accompagnant le bouton 'On se dévoile'", $content);
|
|
$data = self::emptyButtonBooleanBloc($data, "'On se dévoile'");
|
|
// @phpcs:enable
|
|
return $data;
|
|
}
|
|
|
|
// * EMPTY BLOCS
|
|
|
|
/**
|
|
* Empty bloc for picture.
|
|
*
|
|
* @param array $data
|
|
* @param string $img
|
|
* @param string $imgAlt
|
|
* @param string $imgTitle
|
|
* @param integer $width
|
|
* @param integer $height
|
|
* @param boolean $required
|
|
* @param string $name
|
|
* @return array
|
|
*/
|
|
private static function emptyPictureBloc(
|
|
array $data,
|
|
string $img = '',
|
|
string $imgAlt = '',
|
|
string $imgTitle = '',
|
|
int $width = 100,
|
|
int $height = 100,
|
|
bool $required = false,
|
|
string $name = 'image',
|
|
) {
|
|
$data[sprintf('bloc_%s', Str::of($name)->snake()->ascii()->remove(['\'', '-']))] = [
|
|
'label' => $name,
|
|
'dimensions' => ['width' => $width, 'height' => $height],
|
|
'inputType' => InputType::image->value,
|
|
'alt' => $imgAlt,
|
|
'title' => $imgTitle,
|
|
'value' => $img,
|
|
'validate' => $required ? 'required' : 'nullable',
|
|
'required' => $required
|
|
];
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Empty bloc for link associated to the picture.
|
|
*
|
|
* @param array $data
|
|
* @param string $url
|
|
* @param boolean $required
|
|
* @return array
|
|
*/
|
|
private static function emptyPictureLinkBloc(
|
|
array $data,
|
|
string $url = '',
|
|
bool $required = false,
|
|
) {
|
|
$data["bloc_image_link"] = [
|
|
'label' => "URL à ouvrir",
|
|
'inputType' => InputType::url->value,
|
|
'value' => $url,
|
|
'validate' => 'url|' . ($required ? 'required' : 'nullable'),
|
|
'required' => $required
|
|
];
|
|
|
|
$data["bloc_image_link_new_tab"] = [
|
|
'label' => "Ouvrir dans un nouvel onglet",
|
|
'inputType' => InputType::boolean->value,
|
|
];
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Empty bloc for key numbers.
|
|
*
|
|
* @param array $data
|
|
* @param string $name
|
|
* @param integer $value
|
|
* @param boolean $required
|
|
*
|
|
* @return array
|
|
*/
|
|
private static function emptyKeyNumberBloc(
|
|
array $data,
|
|
string $name,
|
|
int $value = 0,
|
|
bool $required = false,
|
|
) {
|
|
$snakeCaseName = Str::of($name)->snake()->ascii()->remove(['\'', '-']);
|
|
|
|
$data['bloc_key_' . $snakeCaseName] = [
|
|
'label' => "Chiffre clé {$name}",
|
|
'inputType' => InputType::number->value,
|
|
'value' => $value,
|
|
'validate' => $required ? 'required' : 'nullable',
|
|
'required' => $required
|
|
];
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Empty bloc for the button boolean.
|
|
*
|
|
* @param array $data
|
|
* @param string $name
|
|
* @return array
|
|
*/
|
|
private static function emptyButtonBooleanBloc(
|
|
array $data,
|
|
string $name
|
|
) {
|
|
$snakeCaseName = Str::of($name)->snake()->ascii()->remove(['\'', '-']);
|
|
|
|
$data["bloc_button_{$snakeCaseName}"] = [
|
|
'label' => "Afficher le bouton {$name} ?",
|
|
'inputType' => InputType::boolean->value,
|
|
'value' => false
|
|
];
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Empty bloc for the h3 title.
|
|
*
|
|
* @param array $data
|
|
* @param string $name
|
|
* @param string $value
|
|
* @param boolean $required
|
|
* @return array
|
|
*/
|
|
private static function emptyStringBloc(
|
|
array $data,
|
|
string $name,
|
|
string $value = '',
|
|
bool $required = false
|
|
) {
|
|
$snakeCaseName = Str::of($name)->snake()->ascii()->remove(['\'', '-']);
|
|
|
|
$data["bloc_string_{$snakeCaseName}"] = [
|
|
'label' => $name,
|
|
'inputType' => InputType::string->value,
|
|
'validate' => 'max:255|' . ($required ? 'required' : 'nullable'),
|
|
'value' => $value,
|
|
'required' => $required
|
|
];
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Empty bloc for the WYSIWYG content.
|
|
*
|
|
* @param array $data
|
|
* @param string $name
|
|
* @param string $value
|
|
* @param \App\Enums\CkEditorConfigName $config
|
|
* @param boolean $required
|
|
* @return array
|
|
*/
|
|
private static function emptyWysiwygBloc(
|
|
array $data,
|
|
string $name,
|
|
string $value = '',
|
|
\App\Enums\CkEditorConfigName $config = \App\Enums\CkEditorConfigName::base,
|
|
bool $required = false
|
|
) {
|
|
$snakeCaseName = Str::of($name)->snake()->ascii()->remove(['\'', '-']);
|
|
|
|
$data["bloc_{$snakeCaseName}_content"] = [
|
|
'label' => "Contenu de la section {$name}",
|
|
'inputType' => InputType::text->value,
|
|
'validate' => $required ? 'required' : 'nullable',
|
|
'value' => $value,
|
|
'required' => $required,
|
|
'config' => $config->name
|
|
];
|
|
|
|
return $data;
|
|
}
|
|
|
|
// * RELATIONS
|
|
|
|
/**
|
|
* Get the page that owns the section.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function page(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(StaticPage::class);
|
|
}
|
|
}
|