PermissionController.php
849 Bytes
<?php
namespace App\Http\Container\AdminSection\Controllers\System;
use App\Models\SystemPermission;
use App\Support\Controller;
use Hikoon\LaravelApi\Facades\Response;
use Illuminate\Http\Request;
class PermissionController extends Controller
{
/**
* @param \Illuminate\Http\Request $request
* @return \Hikoon\LaravelApi\Facades\Response
*/
public function index(Request $request): Response
{
$pageSize = $request->get('pageSize', 20);
$filter = $request->except('page', 'pageSize', 'fetchType');
$fetchType = $request->get('fetchType', 'page');
$build = SystemPermission::filter($filter);
return match ($fetchType) {
'all' => $this->successWithData($build->get()),
default => $this->successWithData($build->paginate($pageSize))
};
}
}