104 lines
2.6 KiB
PHP
104 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace plugin\admin\app\controller;
|
|
|
|
use support\Request;
|
|
use support\Response;
|
|
use plugin\admin\app\model\LogisticsShip;
|
|
use plugin\admin\app\controller\Crud;
|
|
use support\exception\BusinessException;
|
|
use util\Util;
|
|
|
|
/**
|
|
* 船舶信息
|
|
*/
|
|
class LogisticsShipController extends Crud
|
|
{
|
|
/**
|
|
* 不需要鉴权的方法
|
|
* @var string[]
|
|
*/
|
|
protected $noNeedAuth = ['getAll'];
|
|
|
|
/**
|
|
* @var LogisticsShip
|
|
*/
|
|
protected $model = null;
|
|
|
|
/**
|
|
* 构造函数
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->model = new LogisticsShip;
|
|
}
|
|
|
|
/**
|
|
* 浏览
|
|
* @return Response
|
|
*/
|
|
public function index(): Response
|
|
{
|
|
$lang = session('lang', 'zh-cn');
|
|
$translations = (array)require __DIR__ . '/../lang/' . $lang . '/ship.php';
|
|
var_dump($translations);
|
|
$common = (array)require __DIR__ . '/../lang/' . $lang . '/common.php';
|
|
$translations = array_merge($common, $translations); // 确保 common.php 的翻译优先
|
|
|
|
// 合并翻译,确保语言文件中的翻译优先
|
|
// $translations = array_merge($required_translations, $translations);
|
|
return view('logistics-ship/index', [
|
|
'lang' => $lang,
|
|
'translations' => $translations
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 插入
|
|
* @param Request $request
|
|
* @return Response
|
|
* @throws BusinessException
|
|
*/
|
|
public function insert(Request $request): Response
|
|
{
|
|
if ($request->method() === 'POST') {
|
|
return parent::insert($request);
|
|
}
|
|
return view('logistics-ship/insert');
|
|
}
|
|
|
|
/**
|
|
* 更新
|
|
* @param Request $request
|
|
* @return Response
|
|
* @throws BusinessException
|
|
*/
|
|
public function update(Request $request): Response
|
|
{
|
|
$id = $request->input('id');
|
|
$lang = session('lang', 'zh-cn');
|
|
$translations = (array)require __DIR__ . '/../lang/' . $lang . '/ship.php';
|
|
$common = (array)require __DIR__ . '/../lang/' . $lang . '/common.php';
|
|
$translations = array_merge($translations, $common);
|
|
|
|
if ($request->method() === 'POST') {
|
|
return parent::update($request);
|
|
}
|
|
return view('logistics-ship/update', [
|
|
'id' => $id,
|
|
// 'data' => $data,
|
|
'lang' => $lang,
|
|
'translations' => $translations
|
|
]);
|
|
}
|
|
|
|
public function getAll()
|
|
{
|
|
$lang = session('lang', 'zh-cn');
|
|
$locations = LogisticsShip::whereIn('status',[0,1])->get();
|
|
return Util::success($locations);
|
|
}
|
|
|
|
}
|