多语言
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace plugin\admin\app\controller;
|
||||
|
||||
@@ -50,7 +51,15 @@ class VehicleController extends Crud
|
||||
*/
|
||||
public function index(): Response
|
||||
{
|
||||
return view('vehicle/index');
|
||||
$lang = session('lang', 'zh-cn');
|
||||
$translations = (array)require __DIR__ . '/../lang/' . $lang . '/vehicle.php';
|
||||
$common = (array)require __DIR__ . '/../lang/' . $lang . '/common.php';
|
||||
$translations = array_merge($translations, $common);
|
||||
|
||||
return view('vehicle/index', [
|
||||
'lang' => $lang,
|
||||
'translations' => $translations
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,10 +70,15 @@ class VehicleController extends Crud
|
||||
*/
|
||||
public function insert(Request $request): Response
|
||||
{
|
||||
if ($request->method() === 'POST') {
|
||||
return parent::insert($request);
|
||||
}
|
||||
return view('vehicle/insert');
|
||||
$lang = session('lang', 'zh-cn');
|
||||
$translations = (array)require __DIR__ . '/../lang/' . $lang . '/vehicle.php';
|
||||
$common = (array)require __DIR__ . '/../lang/' . $lang . '/common.php';
|
||||
$translations = array_merge($translations, $common);
|
||||
|
||||
return view('vehicle/insert', [
|
||||
'lang' => $lang,
|
||||
'translations' => $translations
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,14 +89,25 @@ class VehicleController extends Crud
|
||||
*/
|
||||
public function update(Request $request): Response
|
||||
{
|
||||
if ($request->method() === 'POST') {
|
||||
return parent::update($request);
|
||||
$id = $request->input('id');
|
||||
$lang = session('lang', 'zh-cn');
|
||||
$translations = (array)require __DIR__ . '/../lang/' . $lang . '/vehicle.php';
|
||||
$common = (array)require __DIR__ . '/../lang/' . $lang . '/common.php';
|
||||
$translations = array_merge($translations, $common);
|
||||
|
||||
$data = Vehicle::where('id', $id)->first();
|
||||
if (!$data) {
|
||||
return json(['code' => 1, 'msg' => $translations['data_not_found'] ?? '数据不存在']);
|
||||
}
|
||||
return view('vehicle/update');
|
||||
|
||||
return view('vehicle/update', [
|
||||
'id' => $id,
|
||||
'data' => $data,
|
||||
'lang' => $lang,
|
||||
'translations' => $translations
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 详情
|
||||
* @param Request $request
|
||||
@@ -91,28 +116,24 @@ class VehicleController extends Crud
|
||||
*/
|
||||
public function detail(Request $request): Response
|
||||
{
|
||||
return view('vehicle/detail');
|
||||
$id = $request->input('id');
|
||||
$lang = session('lang', 'zh-cn');
|
||||
$translations = (array)require __DIR__ . '/../lang/' . $lang . '/vehicle.php';
|
||||
$common = (array)require __DIR__ . '/../lang/' . $lang . '/common.php';
|
||||
$translations = array_merge($translations, $common);
|
||||
|
||||
$data = Vehicle::where('id', $id)->first();
|
||||
if (!$data) {
|
||||
return json(['code' => 1, 'msg' => $translations['data_not_found'] ?? '数据不存在']);
|
||||
}
|
||||
|
||||
return view('vehicle/detail', [
|
||||
'data' => $data,
|
||||
'lang' => $lang,
|
||||
'translations' => $translations
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
* @throws BusinessException
|
||||
*/
|
||||
/* public function list(Request $request)
|
||||
{
|
||||
[$where, $format, $limit, $field, $order] = $this->selectInput($request);
|
||||
return json($where);
|
||||
$query = $this->doSelect($where, $field, $order);
|
||||
$data = $this->doFormat($query, $format, $limit);
|
||||
// foreach ($data['data'] as &$value) {
|
||||
// $value['locations'] = Location::find($value['locations_id'])->name;
|
||||
// }
|
||||
// $data = json_decode(json_encode($data), true);
|
||||
return $data;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 查询后置处理,添加位置信息
|
||||
* @param mixed $items
|
||||
@@ -129,13 +150,6 @@ class VehicleController extends Crud
|
||||
$fbo_location = Location::find($item->fbo_locations_id);
|
||||
$item->fbo_location_name = $fbo_location ? $fbo_location->name : '';
|
||||
|
||||
// if(!str_starts_with($item['img_url'], 'http')){
|
||||
// $ossservice = new OssService();
|
||||
// $img_url = $ossservice->generatePrivateUrl($item['img_url'], 3600);
|
||||
// $item['img_url'] = $img_url;
|
||||
// }
|
||||
|
||||
|
||||
if(!str_starts_with($item['img_url'], 'http')){
|
||||
try {
|
||||
$ossservice = new OssService();
|
||||
|
||||
Reference in New Issue
Block a user