validated(); // Handle the logo upload if it exists if ($request->hasFile('logo')) { $logoPath = $request->file('logo')->store('logos', 'public'); $validatedData['logo'] = $logoPath; } // Create the company with the validated data $company = \App\Models\Company::create($validatedData); // Redirect or return a response return redirect()->route('companies.index')->with('success', 'Company created successfully.'); } public function show(Company $company) { return view('companies.show', compact('company')); } public function edit(Company $company) { return view('companies.edit', compact('company')); } public function update(CompanyRequest $request, Company $company) { // Store the validated data from the form $validatedData = $request->validated(); // Handle the logo upload if it exists if ($request->hasFile('logo')) { $logoPath = $request->file('logo')->store('logos', 'public'); $validatedData['logo'] = $logoPath; } // Update the company with the validated data $company->update($validatedData); // Redirect or return a response return redirect()->route('companies.index')->with('success', 'Company updated successfully.'); } public function destroy(Company $company) { $company->delete(); return redirect()->route('companies.index')->with('success', 'Company deleted successfully.'); } }