StatusController.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Themes\kbgolf\pro\app\Http\Controllers\Post;
  3. use App\Http\Controllers\Controller;
  4. use App\Services\CallApiService;
  5. use App\Services\PostService;
  6. use Illuminate\Pagination\LengthAwarePaginator;
  7. class StatusController extends Controller
  8. {
  9. private $callApiService;
  10. public function __construct(CallApiService $callApiService, PostService $iammgoService)
  11. {
  12. $this->callApiService = $callApiService;
  13. $this->iammgoService = $iammgoService;
  14. }
  15. public function show($id)
  16. {
  17. $limit = (int)request('limit', 10);
  18. $page = (int)request('page', 1);
  19. $postDetailsBook = $this->iammgoService->getPostDetailsBook($id, $limit, $page);
  20. if ($this->callApiService->verifyApiError($postDetailsBook)) {
  21. notify()->error($postDetailsBook['body'], 'Error', 'bottomRight');
  22. return redirect()->to('/');
  23. }
  24. $event = $postDetailsBook['PostDetailsPage'][0];
  25. if ($event['AttachedFiles']) {
  26. $event['AttachedFiles'] = explode('|', $event['AttachedFiles']);
  27. } else {
  28. $event['AttachedFiles'] = [];
  29. }
  30. $postDetailsBook['PostBdPage'] = new LengthAwarePaginator($postDetailsBook['PostBdPage'], $postDetailsBook['PostBdPageVars']['QueryCnt'],
  31. $limit, $page, ['path' => request()->url()]);
  32. // dd($event);
  33. return view('views.page.status-details', compact('event', 'postDetailsBook'))->with('codeTitle', [
  34. "status('post-event')",
  35. ]);
  36. }
  37. }