Ability to configure per page number

This commit is contained in:
Dennis
2021-09-23 14:22:01 +02:00
parent 5cf77fde1c
commit 34da2f563d
7 changed files with 17 additions and 10 deletions

View File

@@ -12,12 +12,12 @@ class ServiceController extends Controller
public function index()
{
return inertia('Admin/Services/Index', [
'servers' => Server::query()->withCount('sites', 'users')->latest()->paginate(5, ['*'], 'servers_per_page'),
'sites' => Site::with('server:id,name')->withCount('users')->latest()->paginate(5, ['*'], 'sites_per_page'),
'servers' => Server::query()->withCount('sites', 'users')->latest()->paginate(config('core.pagination.per_page'), ['*'], 'servers_per_page'),
'sites' => Site::with('server:id,name')->withCount('users')->latest()->paginate(config('core.pagination.per_page'), ['*'], 'sites_per_page'),
'providers' => Provider::query()
->withCount('regions', 'plans', 'servers')
->latest()
->paginate(5, ['*'], 'providers_per_page'),
->paginate(config('core.pagination.per_page'), ['*'], 'providers_per_page'),
]);
}
}

View File

@@ -16,7 +16,7 @@ class UserController extends Controller
return $query->where('name', 'like', '%' . $value . '%')->orWhere('email', 'like', '%' . $value . '%');
})
->latest()
->paginate(5);
->paginate(config('core.pagination.per_page'));
return inertia('Admin/Users/Index', [
'filters' => request()->all('search'),
@@ -57,9 +57,9 @@ class UserController extends Controller
{
$user = User::query()->findOrFail($id);
$servers = $user->servers()->withCount('sites')->latest()->paginate(5, ['*'], 'page_servers');
$servers = $user->servers()->withCount('sites')->latest()->paginate(config('core.pagination.per_page'), ['*'], 'page_servers');
$sites = $user->sites()->with('server:id,name')->latest()->paginate(5, ['*'], 'page_sites');
$sites = $user->sites()->with('server:id,name')->latest()->paginate(config('core.pagination.per_page'), ['*'], 'page_sites');
return inertia('Admin/Users/Show', [
'user' => $user,

7
config/core.php Normal file
View File

@@ -0,0 +1,7 @@
<?php
return [
'pagination' => [
'per_page' => env('PAGINATION_PER_PAGE', 5)
]
];

2
public/js/app.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -142,7 +142,7 @@ export default {
computed: {
hasAccessToServers () {
return this.$page.props.auth.can.length && (this.$page.props.auth.can.servers.create || this.$page.props.auth.can.servers.update || this.$page.props.auth.can.servers.delete);
return Object.keys(this.$page.props.auth.can).length && (this.$page.props.auth.can.servers.create || this.$page.props.auth.can.servers.update || this.$page.props.auth.can.servers.delete);
}
},

View File

@@ -50,7 +50,7 @@ export default {
title: this.__('Sites'),
to: this.route('sites.index'),
},
this.$page.props.auth.can.length && (this.$page.props.auth.can.servers.create || this.$page.props.auth.can.servers.update || this.$page.props.auth.can.servers.delete) ? {
Object.keys(this.$page.props.auth.can).length && (this.$page.props.auth.can.servers.create || this.$page.props.auth.can.servers.update || this.$page.props.auth.can.servers.delete) ? {
title: this.__('Servers'),
to: this.route('servers.index'),
} : null,

View File

@@ -42,7 +42,7 @@ export default {
to: this.route('sites.index'),
active: this.route().current('sites.*')
},
this.$page.props.auth.can.length && (this.$page.props.auth.can.servers.create || this.$page.props.auth.can.servers.update || this.$page.props.auth.can.servers.delete) ? {
Object.keys(this.$page.props.auth.can).length && (this.$page.props.auth.can.servers.create || this.$page.props.auth.can.servers.update || this.$page.props.auth.can.servers.delete) ? {
title: this.__('Servers'),
to: this.route('servers.index'),
} : null,