fbo港口

This commit is contained in:
2025-04-25 11:30:44 +08:00
commit 5218549a4d
42 changed files with 6304 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace app\controller;
use support\Request;
class IndexController
{
public function index(Request $request)
{
static $readme;
if (!$readme) {
$readme = file_get_contents(base_path('README.md'));
}
return $readme;
}
public function view(Request $request)
{
return view('index/view', ['name' => 'webman']);
}
public function json(Request $request)
{
return json(['code' => 0, 'msg' => 'ok']);
}
}
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace app\controller;
use app\model\Location;
use app\util\Util;
use support\Request;
class LocationController
{
/**
* Get all locations that have vehicles
*/
public function index(Request $request)
{
$locations = Location::hasVehicles()
->with('vehicles')
->get()
->map(function ($location) {
$location->vehicle_count = $location->vehicles->count();
return $location;
});
return Util::success($locations);
}
/**
* Get a specific location with its vehicles
*/
public function show(Request $request, $id)
{
$location = Location::hasVehicles()
->with('vehicles')
->find($id);
if (!$location) {
return Util::fail(null, 'Location not found or has no vehicles');
}
return Util::success($location);
}
}
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace app\controller;
use app\model\Vehicle;
use app\util\Util;
use support\Request;
class VehicleController
{
/**
* Mask VIN number by showing only first 2 and last 6 characters
*/
private function maskVin($vin)
{
if (strlen($vin) <= 8) {
return $vin;
}
return substr($vin, 0, 2) . str_repeat('*', strlen($vin) - 8) . substr($vin, -6);
}
/**
* Get all vehicles with their locations
*/
public function index(Request $request)
{
$vehicles = Vehicle::with('location')->with('finalLocation')->get();
$vehicles->each(function ($vehicle) {
if (isset($vehicle->vin)) {
$vehicle->vin = $this->maskVin($vehicle->vin);
}
});
$result = ['list' => $vehicles,'count'=>count($vehicles)];
return Util::success($result);
}
/**
* Get a specific vehicle with its location
*/
public function show(Request $request, $id)
{
$vehicle = Vehicle::with('location')->find($id);
if (!$vehicle) {
return Util::fail($vehicle,'Vehicle not found');
}
if (isset($vehicle->vin)) {
$vehicle->vin = $this->maskVin($vehicle->vin);
}
return Util::success($vehicle);
}
}