Additional Changes
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Equipments\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Equipments\Models\EquipmentSpecification;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SpecificationController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255|unique:equipment_specifications,name',
|
||||
'description' => 'nullable|string',
|
||||
]);
|
||||
|
||||
EquipmentSpecification::create([
|
||||
'ulid' => (string) Str::ulid(),
|
||||
'name' => $validated['name'],
|
||||
'description' => $validated['description'] ?? null,
|
||||
]);
|
||||
|
||||
return redirect()->back()->with('success', 'Specification added successfully.');
|
||||
}
|
||||
|
||||
public function update(Request $request, EquipmentSpecification $equipmentSpecification)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255|unique:equipment_specifications,name,' . $equipmentSpecification->id,
|
||||
'description' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$equipmentSpecification->update($validated);
|
||||
|
||||
return redirect()->back()->with('success', 'Specification updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(EquipmentSpecification $equipmentSpecification)
|
||||
{
|
||||
$equipmentSpecification->delete();
|
||||
return redirect()->back()->with('success', 'Specification deleted successfully.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user