/** * get Rules of role * * @return array */ public function getRole() { return Role::find($this->role_id); }
/** * Delete role * * @param type $id * @param type $token * @return type */ public function delete($id, $token) { if (csrf_token() != $token) { return redirect()->route($this->prefixPathRoute . 'list')->withErrors('Error token key!'); } $model = Role::find($id); if (!count($model)) { return redirect()->route($this->prefixPathRoute . 'list')->withErrors('Not found item'); } try { $model->delete(); $messages = array('success' => ['Delete item success!']); return redirect()->route($this->prefixPathRoute . 'list')->with('messages', $messages); } catch (Exception $ex) { return redirect()->route($this->prefixPathRoute . 'list')->withErrors($ex); } }