관리-도구
편집 파일: products.blade.php
@extends('layouts.app') @section('content') <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script> <link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-lite.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-lite.min.js"></script> <div class="main-panel"> <div class="content-wrapper"> <div class="row"> <div class="col-lg-12 grid-margin stretch-card"> <div class="card"> <div class="card-body"> <div class="d-flex justify-content-between"> <h3><b>Products</b></h3> <button class="btn btn-success" data-toggle="modal" data-target="#addProject">Add Product +</button> </div> <hr> <div class="table-responsive"> <table class="table table-hover"> <thead> <tr> <th>#</th> <th>Category</th> <th>Title</th> <th>Description</th> <th>Images</th> <th class="text-center">Action</th> </tr> </thead> <tbody> @foreach ($products as $project) <tr> <td>{{ $loop->iteration }}</td> <td>{{ optional($project->category)->productcategory }}</td> <td>{{ $project->title }}</td> <td style="max-width: 300px; white-space: normal; word-wrap: break-word;"> {!! $project->description !!} </td> <td> @if($project->images) @foreach(json_decode($project->images) as $img) <img src="{{ asset('storage/'.$img) }}" style="width:60px;height:60px;object-fit:cover;"> @endforeach @endif </td> <td class="text-center"> <button class="btn btn-primary" data-toggle="modal" data-target="#updateProject{{$project->id}}"> Edit </button> <form method="post" action="{{ route('admin-products.destroy', $project->id) }}" style="display:inline-block"> @csrf @method('DELETE') <button class="btn btn-danger">Delete</button> </form> </td> </tr> <!-- Update Modal --> <div class="modal fade" id="updateProject{{$project->id}}"> <div class="modal-dialog modal-dialog-centered"> <div class="modal-content"> <div class="modal-header"> <h5>Update Product</h5> <button type="button" class="close" data-dismiss="modal">×</button> </div> <div class="modal-body"> <form method="post" action="{{ route('admin-products.update', $project->id) }}" enctype="multipart/form-data"> @csrf @method('PUT') <div class="form-group"> <label>Product Category</label> <select class="form-control" name="productcategory_id" required> @foreach($categories as $cat) <option value="{{ $cat->id }}" {{ $project->productcategory_id == $cat->id ? 'selected' : '' }}> {{ $cat->productcategory }} </option> @endforeach </select> </div> <div class="form-group"> <label>Title</label> <input type="text" name="title" class="form-control" value="{{ $project->title }}"> </div> <div class="form-group"> <label for="description">Description</label> <textarea name="description" class="form-control summernotes" rows="4" placeholder="Enter description">{!! old('description', $project->description) !!}</textarea> </div> <div class="form-group"> <label>Upload Images (Multiple)</label> <input type="file" name="images[]" class="form-control" accept="image/*" multiple> </div> <button type="submit" class="btn btn-primary w-100">Update</button> </form> </div> </div> </div> </div> @endforeach </tbody> </table> </div> </div> </div> </div> </div> <!-- Add Modal --> <div class="modal fade" id="addProject"> <div class="modal-dialog modal-dialog-centered"> <div class="modal-content"> <div class="modal-header"> <h5>Add Product</h5> <button type="button" class="close" data-dismiss="modal">×</button> </div> <div class="modal-body"> <form method="post" action="{{ route('admin-products.store') }}" enctype="multipart/form-data"> @csrf <div class="form-group"> <label>Product Category</label> <select class="form-control" name="productcategory_id" required> <option value="">Select Category</option> @foreach($categories as $cat) <option value="{{ $cat->id }}">{{ $cat->productcategory }}</option> @endforeach </select> </div> <div class="form-group"> <label>Title</label> <input type="text" name="title" class="form-control"> </div> <div class="form-group"> <label for="description">Description</label> <textarea name="description" class="form-control summernote" rows="4" placeholder="Enter description"></textarea> </div> <div class="form-group"> <label>Images (Multiple)</label> <input type="file" name="images[]" class="form-control" accept="image/*" multiple> </div> <button type="submit" class="btn btn-primary w-100">Submit</button> </form> </div> </div> </div> </div> </div> </div> </div> <script> $('.summernote').summernote({ placeholder: 'Description', tabsize: 2, height: 120, toolbar: [ ['style', ['style']], ['font', ['bold', 'underline', 'clear']], ['color', ['color']], ['para', ['ul', 'ol', 'paragraph']], ['table', ['table']], ['insert', ['link', 'picture', 'video']], ['view', ['fullscreen', 'codeview', 'help']] ] }); </script> <script> $('.summernotes').summernote({ placeholder: 'Description', tabsize: 2, height: 120, toolbar: [ ['style', ['style']], ['font', ['bold', 'underline', 'clear']], ['color', ['color']], ['para', ['ul', 'ol', 'paragraph']], ['table', ['table']], ['insert', ['link', 'picture', 'video']], ['view', ['fullscreen', 'codeview', 'help']] ] }); </script> @endsection