add.blade.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. @extends('layouts.idara.panel')
  2. @section('content')
  3. <link href="https://unpkg.com/filepond@4.30.4/dist/filepond.min.css" rel="stylesheet" type="text/css" />
  4. <link href="https://unpkg.com/filepond-plugin-file-poster@2.5.1/dist/filepond-plugin-file-poster.min.css" rel="stylesheet" type="text/css" />
  5. <link href="{{asset('pintura/pintura.scss')}}" rel="stylesheet" />
  6. <!-- Custom css -->
  7. <link href="{{asset('css/custom.css')}}" rel="stylesheet" />
  8. @include('backend.partials.import')
  9. @include('backend.partials.features')
  10. <div class="card mt-4">
  11. <div class="card-header">
  12. Vous pouvez ajouter une image ou la modifie
  13. </div>
  14. <div class="card-body">
  15. <div class="container">
  16. @if(session('success'))
  17. <div class="alert alert-success">
  18. {{ session('success') }}
  19. </div>
  20. @endif
  21. @if (count($errors) > 0)
  22. <div class="alert alert-danger">
  23. <strong>Whoops!</strong> Some problems with your input.<br><br>
  24. <ul>
  25. @foreach ($errors->all() as $error)
  26. <li>{{ $error }}</li>
  27. @endforeach
  28. </ul>
  29. </div>
  30. @endif
  31. <form method="post" action="{{url('produit')}}" enctype="multipart/form-data">
  32. @csrf
  33. <div class="row">
  34. <div class="form-group mt-4">
  35. <label for="exampleFormControlTextarea1"><strong>Nom du produit :</strong></label>
  36. <input type="text" class="form-control" id="" name="nom" placeholder="Nom" required>
  37. </div>
  38. <div class="form-group categorie mt-4" id="categorie">
  39. <label class="" for="exampleFormControlInput1"><strong>Categorie</strong> :</label>
  40. <br>
  41. <select onchange="optionCheck()" class="form-control" name="categorie" id="categorie" class="form-control categorie" aria-describedby="validationServer04Feedback" style=" margin-bottom: 40px;" >
  42. <option>Vueillez selectionner une categorie</option>
  43. @foreach ($categories as $categorie)
  44. <option value="{{ $categorie->id }}" {{ old('categorie') == $categorie->id ? 'selected' : '' }}>{{ $categorie->nom }}</option>
  45. @endforeach
  46. </select>
  47. </div>
  48. <div class="form-group mt-4">
  49. <label for="exampleFormControlTextarea1"><strong>description :</strong></label>
  50. <textarea class="form-control" id="presentation" name="description" rows="6"></textarea>
  51. </div>
  52. <div class="input-group mt-4 control-group increment" >
  53. <input type="file" name="image" class="my-pond form-control" />
  54. </div>
  55. </div>
  56. <div class="form-group col-md-4 mt-4">
  57. <button type="submit" class="btn btn-success" style="margin-top:10px">Upload Image</button>
  58. </div>
  59. </form>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. @include('backend.partials.upload')
  65. <style>
  66. .ck.ck-editor__main>.ck-editor__editable:not(.ck-focused) {
  67. border-color: var(--ck-color-base-border);
  68. height: 300px;
  69. }
  70. </style>
  71. <script src="https://unpkg.com/filepond@4.30.4/dist/filepond.min.js"></script>
  72. <script src="https://unpkg.com/filepond-plugin-file-poster@2.5.1/dist/filepond-plugin-file-poster.min.js"></script>
  73. <script src="https://unpkg.com/filepond-plugin-file-validate-type@1.2.8/dist/filepond-plugin-file-validate-type.min.js"></script>
  74. <script src="https://unpkg.com/filepond-plugin-file-validate-size@2.2.8/dist/filepond-plugin-file-validate-size.min.js"></script>
  75. <script src="https://unpkg.com/filepond-plugin-image-exif-orientation@1.0.11/dist/filepond-plugin-image-exif-orientation.min.js"></script>
  76. <script src="https://cdn.ckeditor.com/ckeditor5/36.0.0/classic/ckeditor.js"></script>
  77. <script>
  78. ClassicEditor
  79. .create(document.querySelector('#presentation'))
  80. .then(editor => {
  81. window.editor = editor;
  82. })
  83. .catch(error => {
  84. console.error('There was a problem initializing the editor.', error);
  85. });
  86. </script>
  87. <script type="module">
  88. var img_width = 1080 ;
  89. var img_height = {{ env('IMG_HEIGHT') }};
  90. var img_quality = {{ env('IMG_QUALITY') }};
  91. var img_ratio = {{ env('IMG_RATIO') }};
  92. var max_files = {{ env('MAX_FILES') }};
  93. var max_file_size = "{{ env('MAX_FILE_SIZE') }}B";
  94. var instant_upload = {{ env('INSTANT_UPLOAD') }};
  95. var pond_selector = '.my-pond';
  96. import {
  97. FilePondPluginImageEditor,
  98. } from '/filepond/filepond-plugin-image-editor/FilePondPluginImageEditor.js';
  99. // import Pintura Image Editor modules
  100. import {
  101. // Image editor
  102. openEditor,
  103. processImage,
  104. createDefaultImageReader,
  105. createDefaultImageWriter,
  106. createDefaultImageOrienter,
  107. // Only needed if loading legacy image editor data
  108. legacyDataToImageState,
  109. // Import the editor default configuration
  110. getEditorDefaults,
  111. } from '/pintura/pintura.js';
  112. // French
  113. import fr_FR from '/filepond/locale/fr-fr.js';
  114. FilePond.setOptions(fr_FR);
  115. // Register plugins
  116. FilePond.registerPlugin(
  117. FilePondPluginImageEditor,
  118. FilePondPluginFilePoster,
  119. FilePondPluginImageExifOrientation,
  120. FilePondPluginFileValidateType,
  121. FilePondPluginFileValidateSize,
  122. );
  123. FilePond.create(document.querySelector(pond_selector), {
  124. // Attributes
  125. name: 'image',
  126. maxFiles: max_files,
  127. allowFileSizeValidation: true,
  128. maxFileSize: max_file_size,
  129. allowBrowse: true,
  130. acceptedFileTypes: ['image/*'],
  131. dropOnPage: true,
  132. dropOnElement: true,
  133. instantUpload: instant_upload,
  134. // FilePond Image Editor plugin properties
  135. imageEditor: {
  136. // Maps legacy data objects to new imageState objects (optional)
  137. legacyDataToImageState: legacyDataToImageState,
  138. // Used to create the editor (required)
  139. createEditor: openEditor,
  140. // Used for reading the image data. See JavaScript installation for details on the `imageReader` property (required)
  141. imageReader: [
  142. createDefaultImageReader,
  143. {
  144. // createDefaultImageReader options here
  145. },
  146. ],
  147. // Required when generating a preview thumbnail and/or output image
  148. imageWriter: [
  149. createDefaultImageWriter,
  150. {
  151. // We'll resize images to fit a 512 × 512 square
  152. targetSize: {
  153. width: img_width,
  154. height: img_height,
  155. },
  156. quality: img_quality,
  157. },
  158. ],
  159. // Used to create poster and output images, runs an invisible "headless" editor instance
  160. imageProcessor: processImage,
  161. // Pintura Image Editor options
  162. editorOptions: {
  163. // Pass the editor default configuration options
  164. ...getEditorDefaults(),
  165. // This will set a square crop aspect ratio
  166. imageCropAspectRatio: img_ratio,
  167. }
  168. }
  169. });
  170. FilePond.setOptions({
  171. server: {
  172. process: '/file-upload-produit',
  173. revert: '/file-delete-produit',
  174. headers:{
  175. 'X-CSRF-TOKEN': '{{ csrf_token() }}'}
  176. },
  177. });
  178. </script>
  179. @endsection