1pppp

Untitled

Aug 12th, 2020
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.69 KB | None | 0 0
  1. @if (Session::has('info'))
  2. <div class="alert alert-success" role="alert">
  3. {{ Session::get('info') }}
  4. </div>
  5. @endif
  6. @extends('admin.index')
  7. @section('content')
  8. <form action="/products/product/edit_store/{{$product->id}}" method="POST">
  9. {{ csrf_field() }}
  10. @if ($errors->any())
  11. <div class="alert alert-danger">
  12. <ul>
  13. @foreach ($errors->all() as $error)
  14. <li>{{ $error }}</li>
  15. @endforeach
  16. </ul>
  17. </div>
  18. @endif
  19. <?php
  20. use Illuminate\Support\MessageBag;
  21. /** @var MessageBag $errors */
  22. ?>
  23. <div class="p-4 mb-2"><h1>Редактирование товара</h1>
  24. <div class="form-group"><label for="inputDesription" class="col-xs-2 control-label">Введите описание(desription)</label>
  25. <div class="col-xs-10">
  26. <input type="text" name="description" class="form-control" placeholder="введите описание" id="desription" value="{{$product->description}}"></div
  27.  
  28. <? if($errors->first("description") != "") echo "<div class='alert'>".$errors->first("description")."</div>"; ?>
  29. </div>
  30. </div>
  31. <div> <label for="inputKeywords" class="col-xs-2 control-label">Введите keywords</label>
  32. <div class="col-xs-10">
  33. <input type="text" name="keywords" placeholder="введите ключевые слова" id="inputKeywords" value="{{$product->keywords}}">
  34. <? if($errors->first("keywords") != "") echo "<div class='alert'>".$errors->first("keywords")."</div>"; ?>
  35. </div>
  36. </div>
  37.  
  38. <div> <div class="form-group"><label for="inputtitle" class="col-xs-2 control-label">Введите заголовок</label>
  39. <div class="col-xs-10">
  40. <input type="text" name="title" placeholder="введите заголовок" id="title" value="{{$product->title}}"></div>
  41. <? if($errors->first("title") != "") echo "<div class='alert'>".$errors->first("title")."</div>"; ?>
  42. </div>
  43. </div>
  44. <div class="form-group"><label for="inputPrice" class="col-xs-2 control-label">Измените цену</label>
  45. <div class="col-xs-10">
  46. <input type="text" name="price" class="form-control" placeholder="введите описание" id="price"v value="{{$product->price}}"></div
  47.  
  48. <? if($errors->first("price") != "") echo "<div class='alert'>".$errors->first("price")."</div>"; ?>
  49. </div>
  50. </div>
  51. <div class="form-group"><label for="inputAuthorized_price" class="col-xs-2 control-label">Измените цену со скидкой</label>
  52. <div class="col-xs-10">
  53. <input type="text" name="authorized_price" class="form-control" placeholder="Введите цену со скидкой" id="authorized_price" value="{{$product->authorized_price}}"></div
  54.  
  55. <? if($errors->first("authorized_price") != "") echo "<div class='alert'>".$errors->first("authorized_price")."</div>"; ?>
  56. </div>
  57. </div>
  58. <!-- --><?php //dd($categories); ?>
  59. {{-- <div class="form-group">--}}
  60. {{-- <label>Подкатегории</label>--}}
  61. {{-- <select class="form-control input-sm" name="category_id">--}}
  62. {{--<!-- --><?php //dd($categories); ?>--}}
  63.  
  64. {{-- <option value="{{$category->id}}">--select--</option>--}}
  65. {{-- @foreach ($categories as $firstcategory)--}}
  66.  
  67. {{-- <option selected value="{{$firstcategory->id}}">{{$firstcategory->title}}</option>--}}
  68. {{-- @if ($firstcategory->categories)--}}
  69. {{-- @foreach ($firstcategory->categories as $subcategory)--}}
  70. {{-- <option value="{{$subcategory->id}}">-----{{$subcategory->title}}</option>--}}
  71. {{-- @endforeach--}}
  72. {{-- @endif--}}
  73. {{-- @endforeach--}}
  74. {{-- </select>--}}
  75. {{-- </div>--}}
  76.  
  77.  
  78. <input type="file" name="path[]" id="path[]" multiple accept="image/*">
  79. <div id="for_preview_uploads">
  80. </div>
  81. {{-- <div>--}}
  82. {{-- строка ниже--}}
  83. {{-- </div>--}}
  84. <script>
  85. function resizeImage(img) {
  86.  
  87. const W = parseInt(img.width / 4);
  88. const H = parseInt(img.height / 4);
  89.  
  90. const canvas = document.createElement("canvas");
  91. canvas.width = W;
  92. canvas.height = H;
  93.  
  94. const ctx = canvas.getContext("2d");
  95. ctx.drawImage(img, 0, 0, W, H);
  96.  
  97. const resizedImg = new Image();
  98. resizedImg.src = canvas.toDataURL('image/jpeg', 1);
  99. //document.body.append(resizedImg);
  100. document.querySelector("#for_preview_uploads").append(resizedImg);
  101.  
  102. }
  103.  
  104. function handleFiles(e) {
  105.  
  106. for (const file of this.files) {
  107.  
  108. const img = document.createElement("img");
  109. const reader = new FileReader();
  110.  
  111. reader.addEventListener("load", (e) => {
  112. img.addEventListener("load", (e) => {
  113. resizeImage(img);
  114. });
  115. img.src = e.target.result;
  116. });
  117.  
  118. reader.readAsDataURL(file);
  119.  
  120. }
  121.  
  122. }
  123.  
  124. const fileInput = document.getElementById("path[]");
  125.  
  126. fileInput.addEventListener("change", handleFiles, false);
  127.  
  128.  
  129. </script>
  130. @forelse ($products as $product)
  131. <div class="products card" style="width: 18rem;">
  132. <div class="card-body">
  133. <p class="card-images">
  134. @forelse ($product->images as $image)
  135. <img src="{{$image->path }} " alt="{{$image->title}}">
  136. @empty
  137. Нет фотографий
  138. @endforelse
  139. </p>
  140. </div>
  141. </div>
  142. @empty
  143. <div>Нет товаров</div>
  144. @endforelse
  145.  
  146. <div class="form-group">
  147. <label>Подкатегории</label>
  148. <select class="form-control input-sm" name="category_id">
  149. <!-- --><?php //dd($categories); ?>
  150. <option selected value="{{$product->id}}">--select--</option>
  151. @foreach ($categories as $firstcategory)
  152. <option @if($firstcategory->id == $category->category_id) selected @endif value="{{$firstcategory->id}}">{{$firstcategory->title}}</option>
  153.  
  154. @if($firstcategory->categories)
  155. @foreach ($firstcategory->categories as $subcategory)
  156. <option @if($subcategory->id == $category->category_id) selected @endif value="{{$subcategory->id}}">-----{{$subcategory->title}}</option>
  157. @endforeach
  158. @endif
  159. @endforeach
  160. </select>
  161. </div>
  162.  
  163. {{-- <div class="form-group">--}}
  164. {{-- <label>Категории</label>--}}
  165. {{-- <select class="form-control input-sm" name="category_id">--}}
  166. {{-- --}}{{-- <!-- --><?php //dd($categories); ?>--}}
  167. {{-- <option selected value="$products->id">--select--</option>--}}
  168. {{-- @foreach ($categories as $firstcategory)--}}
  169. {{-- <option value="{{$firstcategory->id}}">{{$firstcategory->title}}</option>--}}
  170.  
  171. {{-- @if($firstcategory->categories)--}}
  172. {{-- @foreach ($firstcategory->categories as $subcategory)--}}
  173. {{-- <option value="{{$subcategory->id}}">-{{$subcategory->title}}</option>--}}
  174. {{-- @if($subcategory->categories)--}}
  175. {{-- @foreach ($subcategory->categories as $sbcategory)--}}
  176. {{-- <option value="{{$sbcategory->id}}">---{{$sbcategory->title}}</option>--}}
  177. {{-- @endforeach--}}
  178. {{-- @endif--}}
  179. {{-- @endforeach--}}
  180. {{-- @endif--}}
  181. {{-- @endforeach--}}
  182. {{-- </select>--}}
  183. </div>
  184.  
  185. <div><div class="form-group"><label for="inputshort_descriptionl" class="col-xs-2 control-label">Введите короткое описание товара</label>
  186. <div class="col-xs-10">
  187. <textarea rows="10" cols="45" name="short_description" placeholder="Введите короткое описание товара">{{$product->text}}</textarea></div>
  188. <? if($errors->first("short_description") != "") echo "<div class='alert'>".$errors->first("short_description")."</div>"; ?>
  189. </div>
  190. </div>
  191. <div> <label for="inputKeywords" class="col-xs-2 control-label">Введите keywords</label>
  192. <div class="col-xs-10">
  193. <input type="text" name="keywords" placeholder="введите ключевые слова" id="inputKeywords" value="{{$product->keywords}}">
  194. <? if($errors->first("keywords") != "") echo "<div class='alert'>".$errors->first("keywords")."</div>"; ?>
  195. </div>
  196. </div>
  197.  
  198. <div><div class="form-group"><label for="inputslug" class="col-xs-2 control-label">Введите урл страницы</label>
  199. <div class="col-xs-10">
  200. <input type="text" name="slug" placeholder="Укажите slug" value="{{$product->slug}}"></div>
  201. <? if($errors->first("slug") != "") echo "<div class='alert'>".$errors->first("slug")."</div>"; ?>
  202. </div>
  203. </div>
  204.  
  205. <div><div class="form-group"><label for="inputtextl" class="col-xs-2 control-label">Введите описание товара</label>
  206. <div class="col-xs-10">
  207. <textarea rows="10" cols="45" name="text" placeholder="введите пост статьи">{{$product->text}}</textarea></div>
  208. <? if($errors->first("text") != "") echo "<div class='alert'>".$errors->first("text")."</div>"; ?>
  209. </div>
  210. </div>
  211.  
  212. <label for="">Статус</label>
  213. <select class="form-control" name="published">
  214. <?php if(isset($products->id)): ?>
  215. <option value="0" <?php if($products->published == 0): ?> selected="" <?php endif; ?>>Не опубликовано</option>
  216. <option value="1" <?php if($products->published == 1): ?> selected="" <?php endif; ?>>Опубликовано</option>
  217. <?php else: ?>
  218. <option value="0">Не опубликовано</option>
  219. <option value="1">Опубликовано</option>
  220. <?php endif; ?>
  221. </select>
  222. <input type="submit" class="btn btn-success" value="Отправить">
  223. </form>
  224.  
  225. <script src="https://cdn.ckeditor.com/4.14.1/standard/ckeditor.js"></script>
  226. <script>
  227. CKEDITOR.replace( 'text' );
  228. </script>
  229. <script>
  230. CKEDITOR.replace( 'short_description' );
  231. </script>
  232. @endsection
  233.  
Add Comment
Please, Sign In to add comment