72 lines
1.6 KiB
PHP
72 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Models\Vehicle;
|
|
|
|
class VehicleController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
return view('vehicles.index');
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create()
|
|
{
|
|
return view('vehicles.create');
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
// This is handled by the Livewire component
|
|
return redirect()->route('vehicles.index');
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*/
|
|
public function show(Vehicle $vehicle)
|
|
{
|
|
// Load relationships for the show page
|
|
$vehicle->load(['customer', 'serviceOrders.assignedTechnician', 'appointments', 'inspections']);
|
|
|
|
return view('vehicles.show', compact('vehicle'));
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit(Vehicle $vehicle)
|
|
{
|
|
return view('vehicles.edit', compact('vehicle'));
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request, Vehicle $vehicle)
|
|
{
|
|
// This is handled by the Livewire component
|
|
return redirect()->route('vehicles.show', $vehicle);
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy(Vehicle $vehicle)
|
|
{
|
|
$vehicle->delete();
|
|
return redirect()->route('vehicles.index')->with('success', 'Vehicle deleted successfully.');
|
|
}
|
|
}
|