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