관리-도구
편집 파일: gallery.blade.php
@extends('layouts.app') @section('content') <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <!-- Bootstrap 4 --> <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.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>Events</b></h3> <button class="btn btn-success" data-toggle="modal" data-target="#addGallery"> Add New Event + </button> </div> <hr> <div class="table-responsive"> <table class="table table-hover"> <thead> <tr> <th>#</th> <th>Title</th> <th>Media / Document</th> <th class="text-center">Action</th> </tr> </thead> <tbody> @foreach ($galleryy as $gallery) @php $ext = $gallery->media ? strtolower(pathinfo($gallery->media, PATHINFO_EXTENSION)) : null; @endphp <tr> <td>{{ $galleryy->firstItem() + $loop->index }}</td> <td>{{ $gallery->title }}</td> <td> {{-- YOUTUBE --}} @if($gallery->youtube_link) <iframe width="200" height="120" src="https://www.youtube.com/embed/{{ $gallery->youtube_link }}" frameborder="0" allowfullscreen> </iframe> {{-- VIDEO --}} @elseif($gallery->media && in_array($ext, ['mp4','webm','ogg'])) <video width="120" controls> <source src="{{ asset('storage/'.$gallery->media) }}" type="video/{{ $ext }}"> </video> {{-- IMAGE --}} @elseif($gallery->media) <img src="{{ asset('storage/'.$gallery->media) }}" width="80"> {{-- DOCUMENT --}} @elseif($gallery->doc) @php $fileName = basename($gallery->doc); $cleanName = preg_replace('/^\d+_/', '', $fileName); @endphp <a href="{{ asset('storage/'.$gallery->doc) }}" target="_blank" class="btn btn-info btn-sm"> 📄 {{ $cleanName }} </a> @endif </td> <td class="text-center"> <button class="btn btn-primary btn-sm my-1" data-toggle="modal" data-target="#updateGallery{{ $gallery->id }}"> <i class="fa fa-pen"></i> </button> <form method="POST" action="{{ route('admin-gallery.destroy', $gallery->id) }}" class="d-inline"> @csrf @method('DELETE') <button class="btn btn-danger btn-sm my-1"> <i class="fa fa-trash"></i> </button> </form> </td> </tr> <!-- ================= UPDATE MODAL ================= --> <div class="modal fade" id="updateGallery{{ $gallery->id }}"> <div class="modal-dialog modal-dialog-centered"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Update Event</h5> <button type="button" class="close" data-dismiss="modal">×</button> </div> <div class="modal-body"> <form method="POST" action="{{ route('admin-gallery.update', $gallery->id) }}" enctype="multipart/form-data"> @csrf @method('PUT') <div class="form-group"> <label>Title</label> <input type="text" name="title" class="form-control" value="{{ $gallery->title }}"> </div> <div class="form-group"> <label>Media File (Image/Video)</label> <input type="file" name="media" class="form-control"> </div> <div class="form-group"> <label>Document File (PDF, DOC, XLS, etc)</label> <input type="file" name="doc" class="form-control"> </div> <div class="form-group"> <label>YouTube Video Link</label> <input type="text" name="youtube_link" class="form-control" value="{{ $gallery->youtube_link }}" placeholder="https://www.youtube.com/watch?v=xxxx"> </div> {{-- Current Preview --}} <div class="text-center mt-3"> @if($gallery->youtube_link) <iframe width="250" height="150" src="https://www.youtube.com/embed/{{ $gallery->youtube_link }}" frameborder="0" allowfullscreen> </iframe> @elseif($gallery->media && in_array($ext, ['mp4','webm','ogg'])) <video width="200" controls> <source src="{{ asset('storage/'.$gallery->media) }}" type="video/{{ $ext }}"> </video> @elseif($gallery->media) <img src="{{ asset('storage/'.$gallery->media) }}" width="150"> @elseif($gallery->doc) <a href="{{ asset('storage/'.$gallery->doc) }}" target="_blank" class="btn btn-info"> 📄 View Current Document </a> @endif </div> <div class="text-center mt-3"> <button class="btn btn-primary w-50">Update</button> </div> </form> </div> </div> </div> </div> @endforeach </tbody> </table> </div> <div class="d-flex justify-content-center mt-3"> {{ $galleryy->links() }} </div> </div> </div> </div> </div> </div> <!-- ================= ADD MODAL ================= --> <div class="modal fade" id="addGallery"> <div class="modal-dialog modal-dialog-centered"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Add New Event</h5> <button type="button" class="close" data-dismiss="modal">×</button> </div> <div class="modal-body"> <form method="POST" action="{{ route('admin-gallery.store') }}" enctype="multipart/form-data"> @csrf <div class="form-group"> <label>Title</label> <input type="text" name="title" class="form-control"> </div> <div class="form-group"> <label>Media File (Image/Video)</label> <input type="file" name="media" class="form-control"> </div> <div class="form-group"> <label>Document File (PDF, DOC, XLS, etc)</label> <input type="file" name="doc" class="form-control"> </div> <div class="form-group"> <label>YouTube Video Link</label> <input type="text" name="youtube_link" class="form-control" placeholder="https://www.youtube.com/watch?v=xxxx"> </div> <div class="text-center"> <button class="btn btn-success w-50">Submit</button> </div> </form> </div> </div> </div> </div> @endsection