Update Slider settings

This commit is contained in:
Sebastien Hattry 2021-12-08 17:32:31 +01:00
parent 960ad7bc2f
commit 2249eac2b1
32 changed files with 313 additions and 37 deletions

21
app/Enums/Page.php Normal file
View file

@ -0,0 +1,21 @@
<?php
namespace App\Enums;
use Kwaadpepper\Enum\BaseEnumRoutable;
/**
* @method static self home()
* @method static self contact()
*/
class Page extends BaseEnumRoutable
{
protected static function values(): array
{
return [
'home' => 0,
'marque' => 1,
'food-service' => 2,
];
}
}

View file

@ -2,6 +2,7 @@
namespace App\Http\Controllers\Bo;
use App\Enums\Page;
use App\Http\Controllers\Controller;
use App\Http\Requests\StoreSliderRequest;
use App\Http\Requests\UpdateSliderRequest;
@ -25,9 +26,9 @@ class SlidersController extends Controller
*
* @return \Illuminate\Http\Response
*/
public function create()
public function create(Slider $slider)
{
return view('back.sliders.create');
return view('back.sliders.create', compact('slider'));
}
/**
@ -39,6 +40,7 @@ class SlidersController extends Controller
public function store(StoreSliderRequest $request)
{
$slider = new Slider($request->validated());
// $slider->page = Page::home();
if (!$slider->saveOrFail()) {
return redirect()->route('bo.sliders.edit', $slider->id)->with('error', 'Le slider n\'a pas été crée');

View file

@ -2,12 +2,15 @@
namespace App\Http\Controllers;
use App\Models\Slider;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function index()
{
return view('front.home');
$slider = Slider::where('published', 1)->first();
return view('front.home', compact('slider'));
}
}

View file

@ -2,6 +2,7 @@
namespace App\Http\Requests;
use App\Enums\Page;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Str;

View file

@ -14,7 +14,7 @@ class UpdateSliderRequest extends StoreSliderRequest
return array_merge(
parent::rules(),
[
'slug' => 'required',
'slug' => 'required|unique:sliders,slug,' . $this->slider->id
]
);
}

View file

@ -2,6 +2,7 @@
namespace App\Models;
// use App\Enums\Page;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
@ -10,6 +11,10 @@ class Slider extends Model
{
use HasFactory;
// public $castEnums = [
// 'page' => Page::class
// ];
protected $fillable = [
'label',
'slug',

View file

@ -12,7 +12,8 @@
"laravel/framework": "^8.65",
"laravel/sanctum": "^2.11",
"laravel/tinker": "^2.5",
"laravel/ui": "^3.3"
"laravel/ui": "^3.3",
"mews/purifier": "^3.3"
},
"require-dev": {
"facade/ignition": "^2.5",

137
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "8f7837eb85b0725169b90fb56c8b1646",
"content-hash": "13cf508d573ec94972a8af8466df849d",
"packages": [
{
"name": "asm89/stack-cors",
@ -422,6 +422,60 @@
],
"time": "2020-12-29T14:50:06+00:00"
},
{
"name": "ezyang/htmlpurifier",
"version": "v4.13.0",
"source": {
"type": "git",
"url": "https://github.com/ezyang/htmlpurifier.git",
"reference": "08e27c97e4c6ed02f37c5b2b20488046c8d90d75"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/08e27c97e4c6ed02f37c5b2b20488046c8d90d75",
"reference": "08e27c97e4c6ed02f37c5b2b20488046c8d90d75",
"shasum": ""
},
"require": {
"php": ">=5.2"
},
"require-dev": {
"simpletest/simpletest": "dev-master#72de02a7b80c6bb8864ef9bf66d41d2f58f826bd"
},
"type": "library",
"autoload": {
"psr-0": {
"HTMLPurifier": "library/"
},
"files": [
"library/HTMLPurifier.composer.php"
],
"exclude-from-classmap": [
"/library/HTMLPurifier/Language/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1-or-later"
],
"authors": [
{
"name": "Edward Z. Yang",
"email": "admin@htmlpurifier.org",
"homepage": "http://ezyang.com"
}
],
"description": "Standards compliant HTML filter written in PHP",
"homepage": "http://htmlpurifier.org/",
"keywords": [
"html"
],
"support": {
"issues": "https://github.com/ezyang/htmlpurifier/issues",
"source": "https://github.com/ezyang/htmlpurifier/tree/master"
},
"time": "2020-06-29T00:56:53+00:00"
},
{
"name": "fruitcake/laravel-cors",
"version": "v2.0.4",
@ -1615,6 +1669,87 @@
],
"time": "2021-09-25T08:23:19+00:00"
},
{
"name": "mews/purifier",
"version": "3.3.6",
"source": {
"type": "git",
"url": "https://github.com/mewebstudio/Purifier.git",
"reference": "1d033fc32b98036226002c38747d4a45424d5f28"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mewebstudio/Purifier/zipball/1d033fc32b98036226002c38747d4a45424d5f28",
"reference": "1d033fc32b98036226002c38747d4a45424d5f28",
"shasum": ""
},
"require": {
"ezyang/htmlpurifier": "4.13.*",
"illuminate/config": "^5.8|^6.0|^7.0|^8.0",
"illuminate/filesystem": "^5.8|^6.0|^7.0|^8.0",
"illuminate/support": "^5.8|^6.0|^7.0|^8.0",
"php": "^7.2|^8.0"
},
"require-dev": {
"graham-campbell/testbench": "^3.2|^5.5.1",
"mockery/mockery": "^1.3.3",
"phpunit/phpunit": "^8.0|^9.0"
},
"suggest": {
"laravel/framework": "To test the Laravel bindings",
"laravel/lumen-framework": "To test the Lumen bindings"
},
"type": "package",
"extra": {
"laravel": {
"providers": [
"Mews\\Purifier\\PurifierServiceProvider"
],
"aliases": {
"Purifier": "Mews\\Purifier\\Facades\\Purifier"
}
}
},
"autoload": {
"psr-4": {
"Mews\\Purifier\\": "src/"
},
"files": [
"src/helpers.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Muharrem ERİN",
"email": "me@mewebstudio.com",
"homepage": "https://github.com/mewebstudio",
"role": "Developer"
}
],
"description": "Laravel 5/6/7 HtmlPurifier Package",
"homepage": "https://github.com/mewebstudio/purifier",
"keywords": [
"Purifier",
"htmlpurifier",
"laravel5 HtmlPurifier",
"laravel5 Purifier",
"laravel5 Security",
"laravel6 HtmlPurifier",
"laravel6 Purifier",
"laravel6 Security",
"security",
"xss"
],
"support": {
"issues": "https://github.com/mewebstudio/Purifier/issues",
"source": "https://github.com/mewebstudio/Purifier/tree/3.3.6"
},
"time": "2021-10-14T15:27:18+00:00"
},
{
"name": "monolog/monolog",
"version": "2.3.5",

114
config/purifier.php Normal file
View file

@ -0,0 +1,114 @@
<?php
/**
* Ok, glad you are here
* first we get a config instance, and set the settings
* $config = HTMLPurifier_Config::createDefault();
* $config->set('Core.Encoding', $this->config->get('purifier.encoding'));
* $config->set('Cache.SerializerPath', $this->config->get('purifier.cachePath'));
* if ( ! $this->config->get('purifier.finalize')) {
* $config->autoFinalize = false;
* }
* $config->loadArray($this->getConfig());
*
* You must NOT delete the default settings
* anything in settings should be compacted with params that needed to instance HTMLPurifier_Config.
*
* @link http://htmlpurifier.org/live/configdoc/plain.html
*/
// phpcs:disable Generic.Files.LineLength.TooLong
return [
'encoding' => 'UTF-8',
'finalize' => true,
'cachePath' => storage_path('app/purifier'),
'cacheFileMode' => 0755,
'settings' => [
'default' => [
'HTML.SafeIframe' => true, // For iframes
'URI.SafeIframeRegexp' => "%^(http://|https://|//)(vimeo.com)%",
'HTML.Doctype' => 'HTML 4.01 Transitional',
'HTML.Allowed' => 'h1[style],h2[style],h3[style],h4[style],h5[style],h6[style],figure[class],oembed[url],div,b,strong,i,em,u,a[href|title],ul[style],ol[style],dl[style],li,p[style],br,span[style|class],img[width|height|alt|src],iframe[src|width|height|class|frameborder],table,thead,tbody,th,tr,td,hr',
'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align,list-style-type',
'AutoFormat.AutoParagraph' => false,
'AutoFormat.RemoveEmpty' => false,
'AutoFormat.RemoveEmpty.RemoveNbsp' => false,
],
"youtube" => [
"HTML.SafeIframe" => 'true',
"URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/|vimeo.com/)%",
],
'custom_definition' => [
'id' => 'html5-definitions',
'rev' => 1,
'debug' => true,
'elements' => [
// http://developers.whatwg.org/sections.html
['section', 'Block', 'Flow', 'Common'],
['nav', 'Block', 'Flow', 'Common'],
['article', 'Block', 'Flow', 'Common'],
['aside', 'Block', 'Flow', 'Common'],
['header', 'Block', 'Flow', 'Common'],
['footer', 'Block', 'Flow', 'Common'],
// Content model actually excludes several tags, not modelled here
['address', 'Block', 'Flow', 'Common'],
['hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common'],
// http://developers.whatwg.org/grouping-content.html
['figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common'],
['figcaption', 'Inline', 'Flow', 'Common'],
['oembed', 'Inline', 'Flow', 'Common'],
// http://developers.whatwg.org/the-video-element.html#the-video-element
['video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [
'src' => 'URI',
'type' => 'Text',
'width' => 'Length',
'height' => 'Length',
'poster' => 'URI',
'preload' => 'Enum#auto,metadata,none',
'controls' => 'Bool',
]],
['source', 'Block', 'Flow', 'Common', [
'src' => 'URI',
'type' => 'Text',
]],
// http://developers.whatwg.org/text-level-semantics.html
['s', 'Inline', 'Inline', 'Common'],
['var', 'Inline', 'Inline', 'Common'],
['sub', 'Inline', 'Inline', 'Common'],
['sup', 'Inline', 'Inline', 'Common'],
['mark', 'Inline', 'Inline', 'Common'],
['wbr', 'Inline', 'Empty', 'Core'],
// http://developers.whatwg.org/edits.html
['ins', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],
['del', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],
],
'attributes' => [
['iframe', 'allowfullscreen', 'Bool'],
['table', 'height', 'Text'],
['td', 'border', 'Text'],
['th', 'border', 'Text'],
['tr', 'width', 'Text'],
['tr', 'height', 'Text'],
['tr', 'border', 'Text'],
['figure', 'class', 'Text'],
['oembed', 'url', 'Text'],
['span', 'style', 'Text'],
],
],
'custom_attributes' => [
['a', 'target', 'Enum#_blank,_self,_target,_top'],
['ol', 'style', 'Text'],
['oembed', 'url', 'Text'],
],
'custom_elements' => [
['u', 'Inline', 'Inline', 'Common'],
['oembed', 'Inline', 'Inline', 'Common'],
],
],
];

View file

@ -8,6 +8,7 @@ use Illuminate\Support\Str;
class UserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*

View file

@ -15,6 +15,7 @@ class CreateSlidersTable extends Migration
{
Schema::create('sliders', function (Blueprint $table) {
$table->id();
$table->smallInteger('page');
$table->string('label');
$table->string('slug')->unique();
$table->string('commentaire')->nullable();

View file

@ -2,9 +2,9 @@
namespace Database\Seeders;
// use App\Enums\Page;
use App\Models\Slide;
use App\Models\Slider;
use Illuminate\Support\Str;
use Illuminate\Database\Seeder;
class SlidersSeeder extends Seeder
@ -16,8 +16,8 @@ class SlidersSeeder extends Seeder
*/
public function run()
{
// Slider::factory(2)->create(['page' => Page::home(),])
Slider::factory(2)->create()
->each(function (Slider $slider) {
$i = 0;

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

View file

Before

Width:  |  Height:  |  Size: 268 KiB

After

Width:  |  Height:  |  Size: 268 KiB

View file

Before

Width:  |  Height:  |  Size: 278 KiB

After

Width:  |  Height:  |  Size: 278 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 268 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 278 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 KiB

View file

@ -5,9 +5,8 @@
@include('back.modules.input-error', ['inputName'=>'slug'])
</div>
<div class="form-group">
<label for="name">{{ __('Commentaire') }}</label>
<input type="text" id="commentaire" name="commentaire" class="form-control" placeholder="{{ __('Commentaire') }}" value="{{ old('commentaire', $slider->commentaire ?? '') }}">
@include('back.modules.input-error', ['inputName'=>'commentaire'])
<label for="commentaire">{{ __('Titre de la page') }}</label>
<textarea class="form-control" placeholder="{{ __('Titre de la page') }}" id="commentaire" name="commentaire" style="height: 100px">{{ old('commentaire', $slider->commentaire ?? '') }}</textarea>
</div>
<div class="form-group">
<input class="form-check-input" type="checkbox" id="publish" name="published" @if (old('published', $slider->published) !== 0)checked @endif>

View file

@ -14,7 +14,7 @@
<table class="table">
<thead>
<th scope="col">{{ __('Label') }}</th>
<th scope="col">{{ __('Commentaire') }}</th>
<th scope="col">{{ __('Titre de la page') }}</th>
<th scope="col">{{ __('Publié') }}</th>
<th></th>
</thead>

View file

@ -64,7 +64,7 @@
</div>
</div>
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
{{-- <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h2><small class="text-muted">{{ __('Options de lien') }}</small></h2>
</div>
<div class="form-group">
@ -81,4 +81,4 @@
<input class="form-check-input" type="checkbox" id="new_tab_cb" name="link_new_tab" @if (old('link_new_tab', $slide->link_new_tab) !== 0)checked @endif>
<label class="form-check-label" for="new_tab_cb">{{ __('Ouvrir dans un nouvel onglet') }}</label>
@include('back.modules.input-error', ['inputName'=>'link_new_tab'])
</div>
</div> --}}

View file

@ -5,26 +5,15 @@
@section('content')
<div class="jumbotron">
<div id="carrousel1">
<div class="item">
<div class="item__image">
<img class="img-zoom" src="{{ asset('assets/images/image-sample.jpg') }}" />
@foreach ($slider->slides as $slide)
<div class="item">
<div class="item__image">
<img class="img-zoom" src="{{ asset($slide->picture) }}" />
</div>
</div>
<a href="#" title="read more about post"></a>
</div>
<div class="item">
<div class="item__image">
<img class="img-zoom" src="{{ asset('assets/images/image-sample.jpg') }}" />
</div>
<a href="#" title="read more about post"></a>
</div>
<div class="item">
<div class="item__image">
<img class="img-zoom" src="{{ asset('assets/images/image-sample.jpg') }}" />
</div>
<a href="#" title="read more about post"></a>
</div>
@endforeach
</div>
<h1 class="item__title maintitle align-center ttu animate__animated fadeIn animate__slow">Doux,<br />Plaisir et qualité<br />à la française</h1>
<h1 class="item__title maintitle align-center ttu animate__animated fadeIn animate__slow">{!! clean(nl2br($slider->commentaire)) !!}</h1>
<div class="banner">
<svg id="Calque_1" data-name="Calque 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1919.76 59.99">
<defs>

View file

@ -10,11 +10,15 @@
</h2>
<div id="collapseOne" class="accordion-collapse collapse" aria-labelledby="headingOne">
<div class="accordion-body">
<div class="mb-1">
<h6 class="pb-1 mb-1 text-dark border-bottom">SLIDER</h6>
<a class="nav-link py-0 ms-4" href="{{route('bo.sliders.index')}}">{{ __('Slider') }}</a>
<a class="nav-link py-0 ms-4" href="{{route('bo.slides.index')}}">{{ __('Slide') }}</a>
</div>
<div class="mb-1">
<h6 class="pb-1 mb-1 text-dark border-bottom">SLIDER</h6>
<a class="nav-link py-0 ms-4" href="{{route('bo.sliders.index')}}">{{ __('Slider') }}</a>
<a class="nav-link py-0 ms-4" href="{{route('bo.slides.index')}}">{{ __('Slide') }}</a>
</div>
{{-- <div class="mb-1">
<h6 class="pb-1 mb-1 text-dark border-bottom">ENCART DE PRESENTATION</h6>
<a class="nav-link py-0 ms-4" href="{{route('bo.sliders.index')}}">{{ __('Présentation') }}</a>
</div> --}}
</div>
</div>
</div>