####### this function is called to go the page where your input date to store data public function create(){ return view('[location of the folder where the table is being displayed]'); } ############ this function is called to to store or create an actual data public function store(Request $request){ $request->validate([ 'title' => 'required|string', 'description' => 'required|string', 'image' => 'nullable|image|mimes:jpg,jpeg,png,gif|max:2048', ]); // Handle the image upload $imagePath = null; // Initialize the image path variable if ($request->hasFile('image')) { $image = $request->file('image'); $imageName = time() . '_' . $image->getClientOriginalName(); $image->move(public_path('images/uploads'), $imageName); // Set the image path if the upload is successful $imagePath = 'images/uploads/' . $imageName; } HomepageModel::create([ 'title' => $request->title, 'description' => $request->description, 'image' => $imagePath, ]); return redirect()->route('homepage.index')->with('success', 'Homepage details added successfully.'); } public function index(){ $homePage = HomepageModel::all(); return view('[location of the folder where the table is being displayed]', compact('homePage')); } ################## this function is called when to go the edit page where you edit the table data public function edit($id){ $homepageModel = HomepageModel::find($id); return view('backend.homepage.edit', compact('homepageModel')); } ################## This data is used to update the actual data in the table public function update(Request $request, $id) { // Validate the request data $request->validate([ 'title' => 'required|string', 'description' => 'required|string', 'image' => 'nullable|image|mimes:jpg,jpeg,png,gif|max:2048', ]); // Find the record to update $homepage = HomepageModel::findOrFail($id); // Handle the image upload $imagePath = $homepage->image; // Retain the old image path if ($request->hasFile('image')) { // Delete the old image if a new image is uploaded if ($imagePath && file_exists(public_path($imagePath))) { unlink(public_path($imagePath)); } // Upload the new image $image = $request->file('image'); $imageName = time() . '_' . $image->getClientOriginalName(); $image->move(public_path('images/uploads'), $imageName); $imagePath = 'images/uploads/' . $imageName; } // Update the record $homepage->update([ 'title' => $request->title, 'description' => $request->description, 'image' => $imagePath, ]); return redirect()->route('homepage.index')->with('success', 'Homepage details updated successfully.'); } #################### this function is called to delete or destroy table data public function destroy($id){ $homepage = HomepageModel::find($id); $homepage->delete(); return redirect()->route('homepage.index')->with('success', 'Homepage details deleted successfully.'); } image title content date #################################################

Add New Homepage

@csrf

Create a New Brand

@error('title') {{ $message }} @enderror
@error('title') {{ $message }} @enderror
@error('title') {{ $message }} @enderror
@error('title') {{ $message }} @enderror
@error('title') {{ $message }} @enderror
@error('title') {{ $message }} @enderror
@error('title') {{ $message }} @enderror
@error('title') {{ $message }} @enderror