错误处理
This commit is contained in:
parent
2336eb5754
commit
13730c5dea
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Exceptions\EmqxSupportException;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Support\EmqxSupport;
|
use App\Support\EmqxSupport;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Pagination\Paginator;
|
use Illuminate\Pagination\Paginator;
|
||||||
|
|
||||||
@ -15,11 +17,15 @@ public function index(Request $request)
|
|||||||
{
|
{
|
||||||
$emqx = new EmqxSupport();
|
$emqx = new EmqxSupport();
|
||||||
|
|
||||||
|
try {
|
||||||
$clients = $emqx->clients([
|
$clients = $emqx->clients([
|
||||||
'clientid' => $request->client_id,
|
'clientid' => $request->client_id,
|
||||||
'username' => $request->username,
|
'username' => $request->username,
|
||||||
'page' => $request->page,
|
'page' => $request->page,
|
||||||
]);
|
]);
|
||||||
|
} catch (EmqxSupportException|ConnectionException $e) {
|
||||||
|
return back()->with('error', $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
// dd($clients);
|
// dd($clients);
|
||||||
return view('admin.device.index', compact('clients'));
|
return view('admin.device.index', compact('clients'));
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
|
@if(isset($clients))
|
||||||
@foreach($clients['data'] as $c)
|
@foreach($clients['data'] as $c)
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@ -81,9 +82,11 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@endif
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@if(isset($clients))
|
||||||
<div class="d-none flex-sm-fill d-sm-flex align-items-sm-center justify-content-sm-end">
|
<div class="d-none flex-sm-fill d-sm-flex align-items-sm-center justify-content-sm-end">
|
||||||
<div>
|
<div>
|
||||||
<ul class="pagination">
|
<ul class="pagination">
|
||||||
@ -101,5 +104,6 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
Loading…
Reference in New Issue
Block a user