Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sarun Mungthanya
SpnPatch-Laravel
Commits
69ecc25c
Commit
69ecc25c
authored
Dec 09, 2024
by
Sarun Mungthanya
Browse files
issue paginate last page and change perpage
parent
2d580162
Changes
11
Show whitespace changes
Inline
Side-by-side
app/Http/Livewire/Pages/Company/CompanyIndex.php
View file @
69ecc25c
...
...
@@ -29,6 +29,7 @@ class CompanyIndex extends Component
public
$showDeleteListModal
=
false
;
public
$showNoPermissionModal
=
false
;
public
$showMessage
=
false
;
public
$totalItems
;
protected
$listeners
=
[
'showCompanyList'
,
'deleteItem'
,
'deleteSelected'
];
public
function
mount
()
...
...
@@ -64,7 +65,7 @@ class CompanyIndex extends Component
$results
=
$query
->
paginate
(
$this
->
perPage
);
$companyTypes
=
CompanyType
::
all
();
$this
->
totalItems
=
$results
->
total
();
return
view
(
'livewire.pages.company.company-index'
,
[
'results'
=>
$results
,
...
...
@@ -76,7 +77,18 @@ class CompanyIndex extends Component
'showDeleteListModal'
=>
$this
->
showDeleteListModal
]);
}
public
function
updatedPerPage
(
$value
)
{
$this
->
adjustPageForNewPerPage
();
}
public
function
adjustPageForNewPerPage
()
{
$lastPage
=
ceil
(
$this
->
totalItems
/
$this
->
perPage
);
if
(
$this
->
page
>
$lastPage
)
{
$this
->
setPage
(
$lastPage
);
}
}
public
function
showCompanyCreateForm
()
{
if
(
!
\
Auth
::
user
()
->
hasPermissions
([
'add-company'
]))
{
...
...
app/Http/Livewire/Pages/Dischargeport/DischargeportIndex.php
View file @
69ecc25c
...
...
@@ -12,7 +12,7 @@ class DischargeportIndex extends Component
public
$action
=
'list'
;
public
$searchBy
,
$message
,
$keyword
,
$perPage
=
20
,
$searchSelected
=
'isocode'
;
public
$totalItems
;
protected
$listeners
=
[
'showdischargeportListForm'
,
'loadPage'
...
...
@@ -49,7 +49,7 @@ class DischargeportIndex extends Component
}
$results
=
$query
->
paginate
(
$this
->
perPage
);
$this
->
totalItems
=
$results
->
total
();
return
view
(
'livewire.pages.dischargeport.dischargeport-index'
,
[
'results'
=>
$results
,
'action'
=>
$this
->
action
,
...
...
@@ -60,7 +60,18 @@ class DischargeportIndex extends Component
{
$this
->
resetPage
();
}
public
function
updatedPerPage
(
$value
)
{
$this
->
adjustPageForNewPerPage
();
}
public
function
adjustPageForNewPerPage
()
{
$lastPage
=
ceil
(
$this
->
totalItems
/
$this
->
perPage
);
if
(
$this
->
page
>
$lastPage
)
{
$this
->
setPage
(
$lastPage
);
}
}
public
function
showdischargeportListForm
()
{
$this
->
action
=
'list'
;
...
...
app/Http/Livewire/Pages/Exchangerate/ExchangerateIndex.php
View file @
69ecc25c
...
...
@@ -14,7 +14,7 @@ class ExchangerateIndex extends Component
public
$action
=
'list'
;
public
$searchBy
,
$editCurrency
,
$editExdate
,
$deleteCurrency
,
$deleteExdate
,
$message
,
$keyword
,
$perPage
=
20
,
$searchSelected
=
'center_conf_exchangerate.currency'
;
public
$selectedExchangerates
=
[];
public
$totalItems
;
protected
$listeners
=
[
'deleteItem'
,
'deleteSelected'
,
...
...
@@ -44,7 +44,7 @@ class ExchangerateIndex extends Component
'center_conf_exchangerate.amenddate'
,
'center_conf_exchangerate_export.baht as exbaht'
)
->
join
(
'center_conf_exchangerate_export'
,
function
(
$join
)
{
->
join
(
'center_conf_exchangerate_export'
,
function
(
$join
)
{
$join
->
on
(
'center_conf_exchangerate.currency'
,
'='
,
'center_conf_exchangerate_export.currency'
)
->
on
(
'center_conf_exchangerate.exdate'
,
'='
,
'center_conf_exchangerate_export.exdate'
)
->
on
(
'center_conf_exchangerate.finishdate'
,
'='
,
'center_conf_exchangerate_export.finishdate'
);
...
...
@@ -60,7 +60,7 @@ class ExchangerateIndex extends Component
->
orderBy
(
'center_conf_exchangerate_export.currency'
,
'DESC'
);
$results
=
$query
->
paginate
(
$this
->
perPage
);
$this
->
totalItems
=
$results
->
total
();
return
view
(
'livewire.pages.exchangerate.exchangerate-index'
,
compact
(
'results'
));
}
...
...
@@ -68,7 +68,18 @@ class ExchangerateIndex extends Component
{
$this
->
resetPage
();
}
public
function
updatedPerPage
(
$value
)
{
$this
->
adjustPageForNewPerPage
();
}
public
function
adjustPageForNewPerPage
()
{
$lastPage
=
ceil
(
$this
->
totalItems
/
$this
->
perPage
);
if
(
$this
->
page
>
$lastPage
)
{
$this
->
setPage
(
$lastPage
);
}
}
public
function
showexchangerateListForm
()
{
$this
->
action
=
'list'
;
...
...
@@ -131,4 +142,3 @@ class ExchangerateIndex extends Component
$this
->
action
=
$page
;
}
}
?>
app/Http/Livewire/Pages/Group/GroupIndex.php
View file @
69ecc25c
...
...
@@ -31,7 +31,8 @@ class GroupIndex extends Component
public
$showDeleteListModal
=
false
;
public
$showNoPermissionModal
=
false
;
public
$showMessage
=
false
;
protected
$listeners
=
[
'showGroupList'
,
'deleteItem'
,
'deleteSelected'
];
public
$totalItems
;
protected
$listeners
=
[
'showGroupList'
,
'deleteItem'
,
'deleteSelected'
];
public
function
mount
()
{
...
...
@@ -52,7 +53,7 @@ class GroupIndex extends Component
$roles
=
Role
::
all
();
$users
=
User
::
all
();
$companies
=
Company
::
all
();
$this
->
totalItems
=
$results
->
total
();
return
view
(
'livewire.pages.group.group-index'
,
[
'results'
=>
$results
,
'route'
=>
$this
->
route
,
...
...
@@ -64,7 +65,18 @@ class GroupIndex extends Component
'showDeleteListModal'
=>
$this
->
showDeleteListModal
]);
}
public
function
updatedPerPage
(
$value
)
{
$this
->
adjustPageForNewPerPage
();
}
public
function
adjustPageForNewPerPage
()
{
$lastPage
=
ceil
(
$this
->
totalItems
/
$this
->
perPage
);
if
(
$this
->
page
>
$lastPage
)
{
$this
->
setPage
(
$lastPage
);
}
}
public
function
showGroupCreateForm
()
{
// if (!\Auth::user()->hasPermissions(['add-group'])) {
...
...
@@ -122,16 +134,15 @@ class GroupIndex extends Component
return
;
}
$groupDeleted
=
Group
::
whereIn
(
"id"
,
$selectedGroups
)
->
pluck
(
'name'
)
->
toArray
();
$groupStr
=
implode
(
","
,
$groupDeleted
);
$groupDeleted
=
Group
::
whereIn
(
"id"
,
$selectedGroups
)
->
pluck
(
'name'
)
->
toArray
();
$groupStr
=
implode
(
","
,
$groupDeleted
);
Group
::
destroy
(
$selectedGroups
);
$message
=
"Deleted : ("
.
$groupStr
.
" )Successfully"
;
$message
=
"Deleted : ("
.
$groupStr
.
" )Successfully"
;
$this
->
message
=
$message
;
$this
->
selectedGroups
=
[];
if
(
$this
->
message
)
{
$this
->
dispatchBrowserEvent
(
'show-message'
,
[
'message'
=>
$this
->
message
]);
}
}
}
app/Http/Livewire/Pages/News/NewsIndex.php
View file @
69ecc25c
...
...
@@ -19,8 +19,8 @@ class NewsIndex extends Component
protected
$paginationTheme
=
'bootstrap'
;
public
$perPage
=
10
;
public
$url
;
public
$searchSelected
=
'topic'
;
public
$searchCateSelected
;
public
$searchSelected
=
'topic'
;
public
$searchCateSelected
;
public
$searchTypeSelected
;
public
$editNewsId
;
public
$deleteNewsId
;
...
...
@@ -29,12 +29,13 @@ class NewsIndex extends Component
public
$searchBy
;
public
$action
=
'list'
;
public
$message
;
public
$selectedNews
=
[]
;
public
$searchCategory
=
[];
public
$selectedNews
=
[];
public
$searchCategory
=
[];
public
$searchType
=
[];
public
$showDeleteListModal
=
false
;
public
$showNoPermissionModal
=
false
;
public
$showMessage
=
false
;
public
$totalItems
;
protected
$listeners
=
[
'showUserList'
,
'deleteItem'
,
'deleteSelected'
,
'setShowMessageFalse'
];
public
function
mount
()
...
...
@@ -53,13 +54,23 @@ class NewsIndex extends Component
$this
->
searchCategory
=
Cache
::
remember
(
'shippingnetservergroup'
,
60
,
function
()
{
return
Shippingnetservergroup
::
all
()
->
pluck
(
'groupname'
,
'groupID'
);
});
}
public
function
search
()
{
$this
->
resetPage
();
}
public
function
updatedPerPage
(
$value
)
{
$this
->
adjustPageForNewPerPage
();
}
public
function
adjustPageForNewPerPage
()
{
$lastPage
=
ceil
(
$this
->
totalItems
/
$this
->
perPage
);
if
(
$this
->
page
>
$lastPage
)
{
$this
->
setPage
(
$lastPage
);
}
}
public
function
showNewsAddForm
()
{
$this
->
action
=
'create'
;
...
...
@@ -112,23 +123,22 @@ class NewsIndex extends Component
$query
=
Shippingnetnews
::
with
(
'group'
);
if
(
!
empty
(
$this
->
searchCateSelected
))
{
if
(
!
empty
(
$this
->
searchCateSelected
))
{
$query
->
where
(
'groupID'
,
$this
->
searchCateSelected
);
}
if
(
!
empty
(
$this
->
searchTypeSelected
))
{
$query
->
where
(
'newstype'
,
$this
->
searchTypeSelected
);
if
(
!
empty
(
$this
->
searchTypeSelected
))
{
$query
->
where
(
'newstype'
,
$this
->
searchTypeSelected
);
}
$results
=
$this
->
searchSelected
&&
$this
->
keyword
?
$query
->
where
(
$this
->
searchSelected
,
'LIKE'
,
'%'
.
$this
->
keyword
.
'%'
)
->
orderBy
(
'shippingnetnews_ID'
,
'desc'
)
->
paginate
(
$this
->
perPage
)
:
$query
->
orderBy
(
'shippingnetnews_ID'
,
'desc'
)
->
paginate
(
$this
->
perPage
);
?
$query
->
where
(
$this
->
searchSelected
,
'LIKE'
,
'%'
.
$this
->
keyword
.
'%'
)
->
orderBy
(
'shippingnetnews_ID'
,
'desc'
)
->
paginate
(
$this
->
perPage
)
:
$query
->
orderBy
(
'shippingnetnews_ID'
,
'desc'
)
->
paginate
(
$this
->
perPage
);
$this
->
totalItems
=
$results
->
total
();
return
view
(
'livewire.pages.news.news-index'
,
[
'results'
=>
$results
,
'selectedNews'
=>
$this
->
selectedNews
,
'showDeleteListModal'
=>
$this
->
showDeleteListModal
]);
}
}
app/Http/Livewire/Pages/Parameter/ParameterIndex.php
View file @
69ecc25c
...
...
@@ -15,7 +15,7 @@ class ParameterIndex extends Component
public
$searchBy
,
$searchByPage
,
$editPid
,
$message
,
$keyword
,
$perPage
=
20
,
$searchSelected
=
'name'
,
$searchSelectedPage
=
''
;
public
$selectedParameters
=
[];
public
$deletePid
;
public
$totalItems
;
protected
$listeners
=
[
'deleteItem'
,
'deleteSelected'
,
...
...
@@ -50,10 +50,21 @@ class ParameterIndex extends Component
$query
->
orderBy
(
'PID'
,
'DESC'
);
$results
=
$query
->
paginate
(
$this
->
perPage
);
$this
->
totalItems
=
$results
->
total
();
return
view
(
'livewire.pages.parameter.parameter-index'
,
compact
(
'results'
));
}
public
function
updatedPerPage
(
$value
)
{
$this
->
adjustPageForNewPerPage
();
}
public
function
adjustPageForNewPerPage
()
{
$lastPage
=
ceil
(
$this
->
totalItems
/
$this
->
perPage
);
if
(
$this
->
page
>
$lastPage
)
{
$this
->
setPage
(
$lastPage
);
}
}
public
function
search
()
{
$this
->
resetPage
();
...
...
app/Http/Livewire/Pages/Patch/PatchIndex.php
View file @
69ecc25c
...
...
@@ -12,6 +12,7 @@ class PatchIndex extends Component
use
WithPagination
;
public
$action
=
'list'
;
public
$searchBy
,
$editPid
,
$message
,
$keyword
,
$perPage
=
10
,
$searchSelected
=
'PID'
,
$selectedPatch
=
[]
;
public
$totalItems
;
protected
$listeners
=
[
'deleteItem'
,
'deleteSelected'
,
'showpatchListForm'
];
public
function
mount
()
{
...
...
@@ -34,9 +35,21 @@ class PatchIndex extends Component
}
$query
->
orderBy
(
'PID'
,
'DESC'
);
$results
=
$query
->
paginate
(
$this
->
perPage
);
$this
->
totalItems
=
$results
->
total
();
return
view
(
'livewire.pages.patch.patch-index'
,
compact
(
'results'
));
}
public
function
updatedPerPage
(
$value
)
{
$this
->
adjustPageForNewPerPage
();
}
public
function
adjustPageForNewPerPage
()
{
$lastPage
=
ceil
(
$this
->
totalItems
/
$this
->
perPage
);
if
(
$this
->
page
>
$lastPage
)
{
$this
->
setPage
(
$lastPage
);
}
}
public
function
search
()
{
$this
->
resetPage
();
...
...
app/Http/Livewire/Pages/Role/RoleIndex.php
View file @
69ecc25c
...
...
@@ -30,6 +30,7 @@ class RoleIndex extends Component
public
$showDeleteListModal
=
false
;
public
$showNoPermissionModal
=
false
;
public
$showMessage
=
false
;
public
$totalItems
;
protected
$listeners
=
[
'showRoleList'
,
'deleteItem'
,
'deleteSelected'
];
public
function
mount
()
...
...
@@ -39,7 +40,18 @@ class RoleIndex extends Component
];
$this
->
message
=
session
(
'message'
);
}
public
function
updatedPerPage
(
$value
)
{
$this
->
adjustPageForNewPerPage
();
}
public
function
adjustPageForNewPerPage
()
{
$lastPage
=
ceil
(
$this
->
totalItems
/
$this
->
perPage
);
if
(
$this
->
page
>
$lastPage
)
{
$this
->
setPage
(
$lastPage
);
}
}
public
function
render
()
{
$results
=
$this
->
searchSelected
&&
$this
->
keyword
...
...
@@ -48,7 +60,7 @@ class RoleIndex extends Component
$permissions
=
Permission
::
orderBy
(
'permission_group_name'
,
'asc'
)
->
get
();
$this
->
totalItems
=
$results
->
total
();
return
view
(
'livewire.pages.role.role-index'
,
[
'results'
=>
$results
,
'route'
=>
$this
->
route
,
...
...
app/Http/Livewire/Pages/SendPatch/SendPatchIndex.php
View file @
69ecc25c
...
...
@@ -20,6 +20,7 @@ class SendPatchIndex extends Component
public
$perPage
=
10
;
public
$searchSelected
=
'PID'
;
public
$action
=
'list'
;
public
$totalItems
;
protected
$listeners
=
[
'showGroupList'
,
'deleteItem'
,
'deleteSelected'
];
...
...
@@ -35,7 +36,18 @@ class SendPatchIndex extends Component
];
$this
->
message
=
session
(
'message'
);
}
public
function
updatedPerPage
(
$value
)
{
$this
->
adjustPageForNewPerPage
();
}
public
function
adjustPageForNewPerPage
()
{
$lastPage
=
ceil
(
$this
->
totalItems
/
$this
->
perPage
);
if
(
$this
->
page
>
$lastPage
)
{
$this
->
setPage
(
$lastPage
);
}
}
public
function
render
()
{
$results
=
[];
...
...
@@ -49,7 +61,7 @@ class SendPatchIndex extends Component
$query
->
orderBy
(
'PID'
,
'DESC'
);
$results
=
$query
->
paginate
(
$this
->
perPage
);
}
$this
->
totalItems
=
$results
->
total
();
return
view
(
'livewire.pages.send-patch.send-patch-index'
,
compact
(
'results'
));
}
...
...
app/Http/Livewire/Pages/ServerLicense/ServerLicenseIndex.php
View file @
69ecc25c
...
...
@@ -12,7 +12,7 @@ class ServerLicenseIndex extends Component
{
use
WithPagination
;
public
$action
=
'list'
;
public
$searchBy
,
$editId
,
$message
,
$keyword
,
$perPage
=
10
,
$searchSelected
=
'COMPANY'
,
$selectedPatch
=
[]
;
public
$searchBy
,
$editId
,
$message
,
$keyword
,
$perPage
=
10
,
$searchSelected
=
'COMPANY'
,
$selectedPatch
=
[]
,
$totalItems
;
protected
$listeners
=
[
'deleteItem'
,
'deleteSelected'
,
'showpatchListForm'
];
public
function
mount
()
{
...
...
@@ -52,9 +52,21 @@ class ServerLicenseIndex extends Component
$query
->
orderBy
(
'ID'
,
'DESC'
);
$results
=
$query
->
paginate
(
$this
->
perPage
);
$this
->
totalItems
=
$results
->
total
();
return
view
(
'livewire.pages.server-license.server-license-index'
,
compact
(
'results'
));
}
public
function
updatedPerPage
(
$value
)
{
$this
->
adjustPageForNewPerPage
();
}
public
function
adjustPageForNewPerPage
()
{
$lastPage
=
ceil
(
$this
->
totalItems
/
$this
->
perPage
);
if
(
$this
->
page
>
$lastPage
)
{
$this
->
setPage
(
$lastPage
);
}
}
public
function
search
()
{
$this
->
resetPage
();
...
...
app/Http/Livewire/Pages/User/UserIndex.php
View file @
69ecc25c
...
...
@@ -29,6 +29,8 @@ class UserIndex extends Component
public
$showDeleteListModal
=
false
;
public
$showNoPermissionModal
=
false
;
public
$showMessage
=
false
;
public
$totalItems
;
protected
$listeners
=
[
'showUserList'
,
'deleteItem'
,
'deleteSelected'
,
'setShowMessageFalse'
];
public
function
mount
()
...
...
@@ -39,6 +41,18 @@ class UserIndex extends Component
// $this->message = session('message');
// $this->showMessage = true;
}
public
function
updatedPerPage
(
$value
)
{
$this
->
adjustPageForNewPerPage
();
}
public
function
adjustPageForNewPerPage
()
{
$lastPage
=
ceil
(
$this
->
totalItems
/
$this
->
perPage
);
if
(
$this
->
page
>
$lastPage
)
{
$this
->
setPage
(
$lastPage
);
}
}
public
function
search
()
{
$this
->
resetPage
();
...
...
@@ -52,7 +66,7 @@ class UserIndex extends Component
:
User
::
paginate
(
$this
->
perPage
);
$this
->
totalItems
=
$results
->
total
();
return
view
(
'livewire.pages.user.user-index'
,
[
'results'
=>
$results
,
'route'
=>
$this
->
route
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment