修复插件不可用
This commit is contained in:
parent
13a6969511
commit
bfa4088b7b
|
|
@ -48,13 +48,16 @@ class MarketingController
|
|||
*/
|
||||
public function show(Request $request)
|
||||
{
|
||||
$code = $request->code;
|
||||
$plugin = MarketingService::getPlugin($code);
|
||||
$data = [
|
||||
'plugin' => $plugin,
|
||||
];
|
||||
|
||||
return view('admin::pages.marketing.show', $data);
|
||||
try {
|
||||
$code = $request->code;
|
||||
$plugin = MarketingService::getPlugin($code);
|
||||
$data = [
|
||||
'plugin' => $plugin,
|
||||
];
|
||||
return view('admin::pages.marketing.show', $data);
|
||||
} catch (\Exception $e) {
|
||||
return redirect(admin_route('marketing.index'))->withErrors(['error' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
namespace Beike\Admin\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class MarketingService
|
||||
{
|
||||
|
|
@ -27,6 +28,10 @@ class MarketingService
|
|||
public static function getPlugin($code)
|
||||
{
|
||||
$url = config('beike.api_url') . '/api/plugins/' . $code;
|
||||
return Http::get($url)->json();
|
||||
$plugin = Http::get($url)->json();
|
||||
if (empty($plugin)) {
|
||||
throw new NotFoundHttpException('该插件不存在或已下架');
|
||||
}
|
||||
return $plugin;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
@section('body-class', 'page-marketing')
|
||||
|
||||
@section('content')
|
||||
@dump($errors)
|
||||
<div id="app" class="card h-min-600" v-cloak>
|
||||
<div class="card-body">
|
||||
<div class="bg-light p-4 mb-4">
|
||||
|
|
|
|||
Loading…
Reference in New Issue