品牌信息
This commit is contained in:
@@ -41,14 +41,28 @@ class BrandController extends BaseController
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
return [
|
||||
$result = [
|
||||
'id' => $item['id'],
|
||||
'status' => $item['status'],
|
||||
'sort' => $item['sort'],
|
||||
'toppic' => $item['toppic'],
|
||||
'descpic' => $item['descpic'],
|
||||
'logo' => $item['logo'],
|
||||
'name' => isset($item['translation']) ? $item['translation']['name'] : '',
|
||||
'desc' => isset($item['translation']) ? $item['translation']['desc'] : '',
|
||||
'toppic_alt' => isset($item['translation']) ? $item['translation']['toppic_alt'] : '',
|
||||
'descpic_alt' => isset($item['translation']) ? $item['translation']['descpic_alt'] : '',
|
||||
'logo_alt' => isset($item['translation']) ? $item['translation']['logo_alt'] : '',
|
||||
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
|
||||
'updated_at' => date('Y-m-d H:i:s', $item['updated_at'])
|
||||
'updated_at' => date('Y-m-d H:i:s', $item['updated_at']),
|
||||
];
|
||||
foreach ($item['banner'] as $k => $v) {
|
||||
$result['banner'][$k] = $v;
|
||||
}
|
||||
foreach ($item['trait'] as $k => $v) {
|
||||
$result['trait'][$k] = $v;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($scene === 'preset') {
|
||||
@@ -86,6 +100,9 @@ class BrandController extends BaseController
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
// $Brand = BrandModel::with('banner')->with('trait')->where('id',314)->first()->toArray();
|
||||
// var_dump($Brand);
|
||||
// return json($Brand);
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
@@ -108,8 +125,8 @@ class BrandController extends BaseController
|
||||
public function add(Request $request): Response
|
||||
{
|
||||
try {
|
||||
return $this->getService()->add($request->all())
|
||||
? $this->successResponse()
|
||||
$id = $this->getService()->add($request->all());
|
||||
return $id ? $this->successResponse(['id' => $id])
|
||||
: $this->errorResponse();
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
@@ -119,11 +136,12 @@ class BrandController extends BaseController
|
||||
public function edit(Request $request, int $id): Response
|
||||
{
|
||||
try {
|
||||
$request->setPost('id',$id);
|
||||
return $this->getService()->edit($request->all(), $id)
|
||||
? $this->successResponse()
|
||||
: $this->errorResponse();
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
return $this->errorResponse($th->getMessage().$th->getFile().$th->getLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user