|
@@ -5,21 +5,22 @@ namespace Themes\kbgolf\pro\app\Http\Controllers\MyPage;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\CallApiService;
|
|
use App\Services\CallApiService;
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
|
|
+use App\Services\PostService;
|
|
|
|
|
|
class NoticeController extends Controller
|
|
class NoticeController extends Controller
|
|
{
|
|
{
|
|
private $callApiService;
|
|
private $callApiService;
|
|
|
|
|
|
- public function __construct(CallApiService $callApiService)
|
|
|
|
|
|
+ public function __construct(CallApiService $callApiService, PostService $postService)
|
|
{
|
|
{
|
|
$this->callApiService = $callApiService;
|
|
$this->callApiService = $callApiService;
|
|
|
|
+ $this->postService = $postService;
|
|
}
|
|
}
|
|
|
|
|
|
public function list()
|
|
public function list()
|
|
{
|
|
{
|
|
$limit = (int)request('limit', 12);
|
|
$limit = (int)request('limit', 12);
|
|
$page = (int)request('page', 1);
|
|
$page = (int)request('page', 1);
|
|
-
|
|
|
|
$noticePage = $this->callApiService->callApi([
|
|
$noticePage = $this->callApiService->callApi([
|
|
'url' => 'list-type1-page',
|
|
'url' => 'list-type1-page',
|
|
'data' => [
|
|
'data' => [
|
|
@@ -38,66 +39,85 @@ class NoticeController extends Controller
|
|
]
|
|
]
|
|
]
|
|
]
|
|
]);
|
|
]);
|
|
|
|
+ // dd($noticePage);
|
|
|
|
+
|
|
|
|
+ $noticePage['Page'] = new LengthAwarePaginator($noticePage['Page'], $noticePage['PageVars']['QueryCnt'],
|
|
|
|
+ $limit, $page, ['path' => request()->url()]);
|
|
|
|
|
|
if ($this->callApiService->verifyApiError($noticePage)) {
|
|
if ($this->callApiService->verifyApiError($noticePage)) {
|
|
notify()->error($noticePage['body'], 'Error', 'bottomRight');
|
|
notify()->error($noticePage['body'], 'Error', 'bottomRight');
|
|
return redirect()->back();
|
|
return redirect()->back();
|
|
}
|
|
}
|
|
|
|
|
|
- $noticePage['Page'] = new LengthAwarePaginator($noticePage['Page'], $noticePage['PageVars']['QueryCnt'],
|
|
|
|
- $limit, $page, ['path' => request()->url()]);
|
|
|
|
-
|
|
|
|
return view('views.my-page.notice-list', compact('noticePage'));
|
|
return view('views.my-page.notice-list', compact('noticePage'));
|
|
}
|
|
}
|
|
|
|
|
|
public function show($id)
|
|
public function show($id)
|
|
{
|
|
{
|
|
- $listType1Book = $this->callApiService->callApi([
|
|
|
|
- 'url' => 'list-type1-book',
|
|
|
|
- 'data' => [
|
|
|
|
- 'Book' => [
|
|
|
|
- [
|
|
|
|
- 'QueryVars' => [
|
|
|
|
- 'QueryName' => 'pro:my-page/post-details',
|
|
|
|
- 'SimpleFilter' => "post_code='notice' and mx.id = $id",
|
|
|
|
- 'IsntPagination' => true,
|
|
|
|
- ],
|
|
|
|
- 'PageVars' => [
|
|
|
|
- 'Limit' => 1
|
|
|
|
- ]
|
|
|
|
- ],
|
|
|
|
- [
|
|
|
|
- 'QueryVars' => [
|
|
|
|
- 'QueryName' => 'pro:my-page/post-details-prenext',
|
|
|
|
- 'SimpleFilter' => "mx.id = (select max(id) from pro_post where id < ${id} and post_type_id = 1) and mx.status != '0'",
|
|
|
|
- 'SubSimpleFilter' => "",
|
|
|
|
- 'IsntPagination' => true,
|
|
|
|
- ],
|
|
|
|
- 'PageVars' => [
|
|
|
|
- 'Limit' => 1
|
|
|
|
- ]
|
|
|
|
- ],
|
|
|
|
- [
|
|
|
|
- 'QueryVars' => [
|
|
|
|
- 'QueryName' => 'pro:my-page/post-details-prenext',
|
|
|
|
- 'SimpleFilter' => "mx.id = (select min(id) from pro_post where id > ${id} and post_type_id = 1) and mx.status != '0'",
|
|
|
|
- 'SubSimpleFilter' => "",
|
|
|
|
- 'IsntPagination' => true,
|
|
|
|
- ],
|
|
|
|
- 'PageVars' => [
|
|
|
|
- 'Limit' => 1
|
|
|
|
|
|
+ $limit = (int)request('limit', 10);
|
|
|
|
+ $page = (int)request('page', 1);
|
|
|
|
+ $postDetailsBook = $this->postService->getPostDetailsBook($id, $limit, $page);
|
|
|
|
+
|
|
|
|
+ if (!empty($postDetailsBook['PostDetailsPage'][0])) {
|
|
|
|
+ $userId = $postDetailsBook['PostDetailsPage'][0]['UserId'];
|
|
|
|
+ $postId = $postDetailsBook['PostDetailsPage'][0]['PostId'];
|
|
|
|
+ // dd($userId);
|
|
|
|
+ if($userId){
|
|
|
|
+ $userPick = $this->callApiService->callApi([
|
|
|
|
+ 'url' => 'users-pick',
|
|
|
|
+ 'data' => [
|
|
|
|
+ 'Page' => [ ['Id' => $userId] ]
|
|
|
|
+ ]
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ if ($this->callApiService->verifyApiError($userPick)) {
|
|
|
|
+ notify()->error($userPick['body'], 'Error', 'bottomRight');
|
|
|
|
+ return redirect()->back();
|
|
|
|
+ }
|
|
|
|
+ // dd($userPick);
|
|
|
|
+ $postDetailsBook['PostDetailsPage'][0]['NickName'] = $userPick['Page'][0]['NickName'];
|
|
|
|
+ }
|
|
|
|
+ if($postId){
|
|
|
|
+ $listType1Book = $this->callApiService->callApi([
|
|
|
|
+ 'url' => 'list-type1-book',
|
|
|
|
+ 'data' => [
|
|
|
|
+ 'Book' => [
|
|
|
|
+ [
|
|
|
|
+ 'QueryVars' => [
|
|
|
|
+ 'QueryName' => 'pro:my-page/post-details-prenext',
|
|
|
|
+ 'SimpleFilter' => "mx.id = (select max(id) from pro_post where id < ${postId} and post_type_id = 1) and mx.status != '0'",
|
|
|
|
+ 'SubSimpleFilter' => "",
|
|
|
|
+ 'IsntPagination' => true,
|
|
|
|
+ ],
|
|
|
|
+ 'PageVars' => [
|
|
|
|
+ 'Limit' => 1
|
|
|
|
+ ]
|
|
|
|
+ ],
|
|
|
|
+ [
|
|
|
|
+ 'QueryVars' => [
|
|
|
|
+ 'QueryName' => 'pro:my-page/post-details-prenext',
|
|
|
|
+ 'SimpleFilter' => "mx.id = (select min(id) from pro_post where id > ${postId} and post_type_id = 1) and mx.status != '0'",
|
|
|
|
+ 'SubSimpleFilter' => "",
|
|
|
|
+ 'IsntPagination' => true,
|
|
|
|
+ ],
|
|
|
|
+ 'PageVars' => [
|
|
|
|
+ 'Limit' => 1
|
|
|
|
+ ]
|
|
|
|
+ ]
|
|
]
|
|
]
|
|
- ],
|
|
|
|
- ]
|
|
|
|
- ]
|
|
|
|
- ]);
|
|
|
|
|
|
+ ]
|
|
|
|
+ ]);
|
|
|
|
|
|
- if ($this->callApiService->verifyApiError($listType1Book)) {
|
|
|
|
- notify()->error($listType1Book['body'], 'Error', 'bottomRight');
|
|
|
|
|
|
+ if ($this->callApiService->verifyApiError($listType1Book)) {
|
|
|
|
+ notify()->error($listType1Book['body'], 'Error', 'bottomRight');
|
|
|
|
+ return redirect()->back();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ notify()->error($postDetailsBook['body'], 'Error', 'bottomRight');
|
|
return redirect()->back();
|
|
return redirect()->back();
|
|
}
|
|
}
|
|
|
|
|
|
-// dump($listType1Book);
|
|
|
|
- return view('views.my-page.notice-details', compact('listType1Book'));
|
|
|
|
|
|
+ return view('views.my-page.notice-details', compact('postDetailsBook', 'listType1Book'));
|
|
}
|
|
}
|
|
}
|
|
}
|