aauth = new Aauth(); $this->request = Services::request(); helper('form'); helper('aauth'); } /** * Index * * @return void */ public function index() { $data = $this->aauth->listPermsPaginated(); $data['cssFiles'] = [ '/assets/css/admin/groups/index.css' ]; echo view('Templates/HeaderAdmin', $data); echo view('Admin/Perms/Home', $data); echo view('Templates/FooterAdmin'); } /** * New * * @return void */ public function new() { echo view('Templates/HeaderAdmin'); echo view('Admin/Perms/New'); echo view('Templates/FooterAdmin'); } /** * Create * * @return void */ public function create() { $name = $this->request->getPost('name'); $definition = $this->request->getPost('definition'); if (! $this->aauth->createPerm($name, $definition)) { return redirect()->back()->with('errors', $this->aauth->getErrorsArray()); } return redirect()->to('/admin/groups'); } /** * Edit * * @return void */ public function edit($permId) { $data['group'] = $this->aauth->getPerm($permId); echo view('Templates/HeaderAdmin'); echo view('Admin/Perms/Edit', $data); echo view('Templates/FooterAdmin'); } /** * Update * * @return void */ public function update($permId) { $name = $this->request->getPost('name'); $definition = $this->request->getPost('definition'); if (! $this->aauth->updatePerm($permId, empty($name) ? null : $name, empty($definition) ? null : $definition)) { return redirect()->back()->with('errors', $this->aauth->getErrorsArray()); } return redirect()->to('/admin/groups/edit/' . $permId); } /** * Show * * @return void */ public function show($permId) { $data['group'] = $this->aauth->getPerm($permId); echo view('Templates/HeaderAdmin'); echo view('Admin/Perms/Show', $data); echo view('Templates/FooterAdmin'); } /** * Delete * * @return void */ public function delete($permId) { if (! $this->aauth->getPerm($permId)) { return redirect()->to('/admin/groups'); } $id = $this->request->getPost('id'); if ($permId === $id) { if ($this->aauth->deletePerm($permId)) { return redirect()->to('/admin/groups'); } } $data['group'] = $this->aauth->getPerm($permId); echo view('Templates/HeaderAdmin'); echo view('Admin/Perms/Delete', $data); echo view('Templates/FooterAdmin'); } }