fixed page error
This commit is contained in:
parent
2d104a0f2c
commit
ac0f1ac48e
|
|
@ -55,9 +55,13 @@ class PagesController
|
|||
*/
|
||||
public function store(PageRequest $request)
|
||||
{
|
||||
$requestData = $request->all();
|
||||
PageRepo::createOrUpdate($requestData);
|
||||
return redirect()->to(admin_route('pages.index'));
|
||||
try {
|
||||
$requestData = $request->all();
|
||||
PageRepo::createOrUpdate($requestData);
|
||||
return redirect(admin_route('pages.index'));
|
||||
} catch (\Exception $e) {
|
||||
return redirect(admin_route('pages.index'))->withErrors(['error' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -85,10 +89,14 @@ class PagesController
|
|||
*/
|
||||
public function update(PageRequest $request, int $pageId)
|
||||
{
|
||||
$requestData = $request->all();
|
||||
$requestData['id'] = $pageId;
|
||||
$page = PageRepo::createOrUpdate($requestData);
|
||||
return redirect()->to(admin_route('pages.index'));
|
||||
try {
|
||||
$requestData = $request->all();
|
||||
$requestData['id'] = $pageId;
|
||||
PageRepo::createOrUpdate($requestData);
|
||||
return redirect()->to(admin_route('pages.index'));
|
||||
} catch (\Exception $e) {
|
||||
return redirect(admin_route('pages.index'))->withErrors(['error' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@
|
|||
namespace Beike\Admin\Repositories;
|
||||
|
||||
use Beike\Models\Page;
|
||||
use Beike\Models\Product;
|
||||
use Beike\Shop\Http\Resources\PageDetail;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
||||
class PageRepo
|
||||
|
|
@ -49,6 +48,19 @@ class PageRepo
|
|||
|
||||
|
||||
public static function createOrUpdate($data)
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$region = self::pushPage($data);
|
||||
DB::commit();
|
||||
return $region;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public static function pushPage($data)
|
||||
{
|
||||
$id = $data['id'] ?? 0;
|
||||
if ($id) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
namespace Beike\Admin\Repositories;
|
||||
|
||||
use Beike\Models\Region;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class RegionRepo
|
||||
{
|
||||
|
|
@ -21,6 +22,19 @@ class RegionRepo
|
|||
}
|
||||
|
||||
public static function createOrUpdate($data)
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$region = self::pushRegion($data);
|
||||
DB::commit();
|
||||
return $region;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public static function pushRegion($data)
|
||||
{
|
||||
$id = $data['id'] ?? 0;
|
||||
if ($id) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
@section('title', '信息页面')
|
||||
|
||||
@section('content')
|
||||
|
||||
@dump($errors)
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body h-min-600">
|
||||
<div class="d-flex justify-content-between mb-4">
|
||||
|
|
|
|||
Loading…
Reference in New Issue