관리-도구
편집 파일: GigController.php
<?php namespace App\Http\Controllers; use App\Gig; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; class GigController extends Controller { public function index() { $gigs = Gig::all(); return view('backend.gigs.index', compact('gigs')); } public function create() { return view('backend.gigs.create'); } public function store(Request $request) { $request->validate([ 'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048', 'link' => 'required|url', ]); // Specify the desired storage path $storagePath = 'public/theme/saintsaccessories/gigs'; // Store the image in the specified path $path = $request->file('image')->store($storagePath); // Create the Gig record Gig::create([ 'image' => $path, 'link' => $request->link, ]); return redirect()->back()->with('success', 'Gig created successfully.'); } public function destroy(Gig $gig) { if (Storage::exists($gig->image)) { Storage::delete($gig->image); } $gig->delete(); return redirect()->back()->with('success', 'Gig deleted successfully.'); } }