add.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. @extends('layouts.idara.panel')
  2. @section('content')
  3. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.15.2/css/selectize.default.min.css" />
  4. <link href="https://unpkg.com/filepond@4.30.4/dist/filepond.min.css" rel="stylesheet" type="text/css" />
  5. <link href="https://unpkg.com/filepond-plugin-file-poster@2.5.1/dist/filepond-plugin-file-poster.min.css" rel="stylesheet"
  6. type="text/css" />
  7. <link href="{{ asset('pintura/pintura.scss') }}" rel="stylesheet" />
  8. <!-- Custom css -->
  9. <link href="{{ asset('css/custom.css') }}" rel="stylesheet" />
  10. @include('backend.partials.import')
  11. @include('backend.partials.features')
  12. <form method="post" action="{{ url('produit') }}" enctype="multipart/form-data">
  13. @csrf
  14. <div class="card mt-4">
  15. <div class="card-header">
  16. Vous pouvez ajouter un produit
  17. </div>
  18. <div class="card-body">
  19. <div class="container">
  20. @if (session('success'))
  21. <div class="alert alert-success">
  22. {{ session('success') }}
  23. </div>
  24. @endif
  25. @if (count($errors) > 0)
  26. <div class="alert alert-danger">
  27. <strong>Whoops!</strong> Some problems with your input.<br><br>
  28. <ul>
  29. @foreach ($errors->all() as $error)
  30. <li>{{ $error }}</li>
  31. @endforeach
  32. </ul>
  33. </div>
  34. @endif
  35. <div class="row">
  36. <div class="form-group mt-4">
  37. <label for="exampleFormControlTextarea1"><strong>Nom du produit :</strong></label>
  38. <input type="text" class="form-control" id="" name="nom" placeholder="Nom"
  39. value="{{ old('nom') }}" required>
  40. </div>
  41. <div class="form-group categorie mt-4" id="categorie">
  42. <label class="" for="exampleFormControlInput1"><strong>Categorie</strong> :</label>
  43. <br>
  44. <select multiple onchange="optionCheck()" class="form-control" name="categories[]"
  45. id="categories" class=" select seletizeData categorie"
  46. aria-describedby="validationServer04Feedback" style=" margin-bottom: 40px;" required>
  47. {{-- <option value=''></option> --}}
  48. @if (!empty(old('categories')))
  49. @foreach (old('categories') as $categorie)
  50. <option value="{{ $categorie }}" selected>
  51. {{ $categories->where('id', $categorie)->first()->nom }}</option>
  52. @endforeach
  53. @endif
  54. @foreach ($categories as $categorie)
  55. <option value="{{ $categorie->id }}"
  56. {{ old('categorie') == $categorie->id ? 'selected' : '' }}> {{ $categorie->nom }}
  57. </option>
  58. @endforeach
  59. </select>
  60. </div>
  61. <div class="form-group mt-4">
  62. <label for="exampleFormControlTextarea1"><strong>description :</strong></label>
  63. <textarea class="form-control" id="presentation" name="description" rows="6" value="">{{ old('description') }}</textarea>
  64. </div>
  65. <div class="input-group mt-4 control-group increment">
  66. <input type="file" name="image" class="my-pond form-control" required />
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. <div class="card mt-4">
  73. <div class="card-header">
  74. Réferencement
  75. </div>
  76. <div class="card-body">
  77. <div class="form-group">
  78. <label for="exampleFormControlInput1" class="mb-3"><strong>Titre(SEO)</strong></label>
  79. <input type="text" class="form-control" name="titre_seo" placeholder="..."
  80. value="{{ old('titre_seo') }}">
  81. </div>
  82. <div class="form-group mt-4">
  83. <label for="exampleFormControlInput1" class="mb-3"><strong>description(SEO)</strong></label>
  84. <textarea name="resume_seo" id="" style="width: 100%" rows="10" value="{{ old('resume_seo') }}"></textarea>
  85. </div>
  86. <div class="form-group mt-4">
  87. <label for="exampleFormControlInput1" class="mb-3"><strong>Mot clé (SEO)</strong></label>
  88. <input type="text" class="form-control" name="mot_cle" placeholder="..."
  89. value="{{ old('mot_cle') }}">
  90. </div>
  91. </div>
  92. </div>
  93. <div class="form-group mt-4 add" style="text-align:end">
  94. <button type="submit" class="btn btn-success" value="Ajouter">Ajouter</button>
  95. </div>
  96. </form>
  97. <style>
  98. .ck.ck-editor__main>.ck-editor__editable:not(.ck-focused) {
  99. border-color: var(--ck-color-base-border);
  100. height: 300px;
  101. }
  102. </style>
  103. @include('backend.partials.scriptIndex')
  104. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.min.js"
  105. integrity="sha512-pumBsjNRGGqkPzKHndZMaAG+bir374sORyzM3uulLV14lN5LyykqNk8eEeUlUkB3U0M4FApyaHraT65ihJhDpQ=="
  106. crossorigin="anonymous" referrerpolicy="no-referrer"></script>
  107. <script src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.15.2/js/selectize.min.js"></script>
  108. <script src="https://unpkg.com/filepond@4.30.4/dist/filepond.min.js"></script>
  109. <script src="https://unpkg.com/filepond-plugin-file-poster@2.5.1/dist/filepond-plugin-file-poster.min.js"></script>
  110. <script src="https://unpkg.com/filepond-plugin-file-validate-type@1.2.8/dist/filepond-plugin-file-validate-type.min.js">
  111. </script>
  112. <script src="https://unpkg.com/filepond-plugin-file-validate-size@2.2.8/dist/filepond-plugin-file-validate-size.min.js">
  113. </script>
  114. <script
  115. src="https://unpkg.com/filepond-plugin-image-exif-orientation@1.0.11/dist/filepond-plugin-image-exif-orientation.min.js">
  116. </script>
  117. <script type="module">
  118. // var img_width = {{ env('IMG_WIDTH') }} ;
  119. // var img_height = {{ env('IMG_HEIGHT') }};
  120. // var img_quality = {{ env('IMG_QUALITY') }};
  121. // var img_ratio = {{ env('IMG_RATIO') }};
  122. // var max_files = {{ env('MAX_FILES') }};
  123. // var max_file_size = "{{ env('MAX_FILE_SIZE') }}B";
  124. // var instant_upload = {{ env('INSTANT_UPLOAD') }};
  125. // var pond_selector = '.my-pond';
  126. var img_width = {{ config('app.IMG_HEIGHT') }} ;
  127. var img_height = {{ config('app.IMG_HEIGHT') }};
  128. var img_quality = {{ config('app.IMG_QUALITY') }};
  129. var img_ratio = {{ config('app.IMG_RATIO') }};
  130. var max_files = {{ config('app.MAX_FILES') }};
  131. var max_file_size = "{{ config('app.MAX_FILE_SIZE') }}B";
  132. var instant_upload = {{ config('app.INSTANT_UPLOAD') }};
  133. var pond_selector = '.my-pond';
  134. import {
  135. FilePondPluginImageEditor,
  136. } from '/filepond/filepond-plugin-image-editor/FilePondPluginImageEditor.js';
  137. // import Pintura Image Editor modules
  138. import {
  139. // Image editor
  140. openEditor,
  141. processImage,
  142. createDefaultImageReader,
  143. createDefaultImageWriter,
  144. createDefaultImageOrienter,
  145. // Only needed if loading legacy image editor data
  146. legacyDataToImageState,
  147. // Import the editor default configuration
  148. getEditorDefaults,
  149. } from '/pintura/pintura.js';
  150. // French
  151. import fr_FR from '/filepond/locale/fr-fr.js';
  152. FilePond.setOptions(fr_FR);
  153. // Register plugins
  154. FilePond.registerPlugin(
  155. FilePondPluginImageEditor,
  156. FilePondPluginFilePoster,
  157. FilePondPluginImageExifOrientation,
  158. FilePondPluginFileValidateType,
  159. FilePondPluginFileValidateSize,
  160. );
  161. FilePond.create(document.querySelector(pond_selector), {
  162. // Attributes
  163. name: 'image',
  164. maxFiles: max_files,
  165. allowFileSizeValidation: true,
  166. maxFileSize: max_file_size,
  167. allowBrowse: true,
  168. acceptedFileTypes: ['image/*'],
  169. dropOnPage: true,
  170. dropOnElement: true,
  171. instantUpload: instant_upload,
  172. // FilePond Image Editor plugin properties
  173. imageEditor: {
  174. // Maps legacy data objects to new imageState objects (optional)
  175. legacyDataToImageState: legacyDataToImageState,
  176. // Used to create the editor (required)
  177. createEditor: openEditor,
  178. // Used for reading the image data. See JavaScript installation for details on the `imageReader` property (required)
  179. imageReader: [
  180. createDefaultImageReader,
  181. {
  182. // createDefaultImageReader options here
  183. },
  184. ],
  185. // Required when generating a preview thumbnail and/or output image
  186. imageWriter: [
  187. createDefaultImageWriter,
  188. {
  189. // We'll resize images to fit a 512 × 512 square
  190. targetSize: {
  191. width: img_width,
  192. height: img_height,
  193. },
  194. quality: img_quality,
  195. },
  196. ],
  197. // Used to create poster and output images, runs an invisible "headless" editor instance
  198. imageProcessor: processImage,
  199. // Pintura Image Editor options
  200. editorOptions: {
  201. // Pass the editor default configuration options
  202. ...getEditorDefaults(),
  203. // This will set a square crop aspect ratio
  204. imageCropAspectRatio: img_ratio,
  205. }
  206. }
  207. });
  208. FilePond.setOptions({
  209. server: {
  210. process: '/file-upload-produit',
  211. revert: '/file-delete-produit',
  212. headers:{
  213. 'X-CSRF-TOKEN': '{{ csrf_token() }}'}
  214. },
  215. });
  216. </script>
  217. <script>
  218. $(function() {
  219. $("#categories").selectize({
  220. plugins: ["remove_button"],
  221. delimiter: ",",
  222. persist: false,
  223. create: function(input) {
  224. return {
  225. value: input,
  226. text: input,
  227. };
  228. },
  229. });
  230. });
  231. </script>
  232. @endsection