@@ -150,7 +150,7 @@ public function store(PageRequest $request)
public function edit($slug)
{
try {
- $page = $this->page->where('slug', $slug)->first();
+ $page = $this->page->where('id', $slug)->first();
return view('themes.default1.agent.kb.pages.edit', compact('page'));
} catch (Exception $e) {
@@ -169,7 +169,7 @@ public function edit($slug)
public function update($slug, PageRequest $request)
{
// get pages with respect to slug
- $pages = $this->page->where('slug', $slug)->first();
+ $pages = $this->page->where('id', $slug)->first();
$sl = $request->input('name');
$slug = Str::slug($sl, '-');
diff --git a/app/Http/Controllers/Agent/kb/SettingsController.php b/app/Http/Controllers/Agent/kb/SettingsController.php
index 50f88d37e0..abd5197a75 100644
--- a/app/Http/Controllers/Agent/kb/SettingsController.php
+++ b/app/Http/Controllers/Agent/kb/SettingsController.php
@@ -42,7 +42,7 @@ public function __construct()
// checking authentication
$this->middleware('auth');
// checking roles
- $this->middleware('roles');
+ $this->middleware('role.agent');
$this->language();
}
diff --git a/app/Http/Controllers/Client/kb/UserController.php b/app/Http/Controllers/Client/kb/UserController.php
index 3a4aa922a0..531d226de2 100644
--- a/app/Http/Controllers/Client/kb/UserController.php
+++ b/app/Http/Controllers/Client/kb/UserController.php
@@ -124,7 +124,7 @@ public function show($slug, Article $article, Category $category)
if ($arti) {
return view('themes.default1.client.kb.article-list.show', compact('arti'));
} else {
- return redirect('404');
+ return Redirect::back()->with('fails', Lang::get('lang.sorry_not_processed'));
}
}
@@ -150,7 +150,6 @@ public function home(Article $article, Category $category, Relationship $relatio
if (Config::get('database.install') == '%0%') {
return redirect('step1');
} else {
- //$categorys = $category->get();
$categorys = $category->get();
// $categorys->setPath('home');
/* direct to view with $article_id */
@@ -235,7 +234,6 @@ public function postComment($slug, Article $article, Request $request, Comment $
{
$request->validate([
'comment' => 'required',
-
]);
$article = $article->where('slug', $slug)->first();
@@ -265,7 +263,16 @@ public function postComment($slug, Article $article, Request $request, Comment $
public function getPage($name, Page $page)
{
- $page = $page->where('slug', $name)->first();
+ $page = $page->where('slug', $name);
+
+ if (!Auth::check() || \Auth::user()->role == 'user') {
+ $page = $page
+ ->where(['status' => 1, 'visibility'=>1])
+ ->first();
+ } else {
+ $page = $page->where('status', 1)->first();
+ }
+
if ($page) {
return view('themes.default1.client.kb.article-list.pages', compact('page'));
} else {
diff --git a/app/Http/Requests/kb/ArticleRequest.php b/app/Http/Requests/kb/ArticleRequest.php
index 4472e62ebe..c6d5c17c60 100644
--- a/app/Http/Requests/kb/ArticleRequest.php
+++ b/app/Http/Requests/kb/ArticleRequest.php
@@ -24,8 +24,7 @@ public function authorize()
public function rules()
{
return [
- 'name' => 'required',
- //'slug' => 'required|unique:kb_article',
+ 'name' => 'required|unique:kb_article',
'description' => 'required',
'category_id' => 'required',
];
diff --git a/app/Http/Requests/kb/ArticleUpdate.php b/app/Http/Requests/kb/ArticleUpdate.php
index c8c3526cd3..129a214502 100644
--- a/app/Http/Requests/kb/ArticleUpdate.php
+++ b/app/Http/Requests/kb/ArticleUpdate.php
@@ -23,11 +23,14 @@ public function authorize()
*/
public function rules()
{
- $id = $this->segments()[1];
+ //$id = $this->segments()[1];
+ $segments = $this->segments();
+
+ $id = isset($segments[1]) ? $segments[1] : null;
return [
- 'name' => 'required',
- 'slug' => 'required|unique:kb_article,slug,'.$id.',id',
+ 'name' => 'required|unique:kb_article,name,'.$id,
+ 'slug' => 'required|unique:kb_article,slug,'.$id,
'description' => 'required',
'category_id' => 'required',
];
diff --git a/app/Http/Requests/kb/PageRequest.php b/app/Http/Requests/kb/PageRequest.php
index 8e9c0daf8c..f9a730ad5a 100644
--- a/app/Http/Requests/kb/PageRequest.php
+++ b/app/Http/Requests/kb/PageRequest.php
@@ -23,10 +23,11 @@ public function authorize()
*/
public function rules()
{
- $slug = $this->segment(2);
+ $id = $this->segment(2);
return [
- 'name' => 'required|unique:kb_pages,slug,'.$slug,
+ 'name' => 'required|unique:kb_pages,name,'.$id,
+ 'description' => 'required',
];
}
}
diff --git a/phpunit.xml b/phpunit.xml
index 45316b2271..b12fae9245 100755
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,27 +1,36 @@
-
-
-
- app/
-
-
+
-
- tests/Feature
+
+ ./tests/
- tests/Unit
+ ./tests/unit
+
+
+ app/
+
+
-
+
+
+
-
+
\ No newline at end of file
diff --git a/resources/views/themes/default1/agent/kb/pages/create.blade.php b/resources/views/themes/default1/agent/kb/pages/create.blade.php
index ce9d18ea40..12c0a6321c 100644
--- a/resources/views/themes/default1/agent/kb/pages/create.blade.php
+++ b/resources/views/themes/default1/agent/kb/pages/create.blade.php
@@ -83,7 +83,7 @@ class="nav-item menu-open"
diff --git a/resources/views/themes/default1/client/kb/article-list/show.blade.php b/resources/views/themes/default1/client/kb/article-list/show.blade.php
index eba6828a3e..b0713481c4 100644
--- a/resources/views/themes/default1/client/kb/article-list/show.blade.php
+++ b/resources/views/themes/default1/client/kb/article-list/show.blade.php
@@ -254,9 +254,22 @@ function submitComment(userId, comment) {
$(".form-group").removeClass("has-error");
// Perform your custom validation here
- var name = $("#comment-name").val().trim();
- var email = $("#comment-email").val().trim();
- var comment = $("#comment-comment").val().trim();
+ var nameElement = $("#comment-name");
+ var emailElement = $("#comment-email");
+ var commentElement = $("#comment-comment");
+
+ if (nameElement.length > 0) {
+ var name = nameElement.val().trim();
+ }
+
+ if (emailElement.length > 0) {
+ var email = emailElement.val().trim();
+ }
+
+ if (commentElement.length > 0) {
+ var comment = commentElement.val().trim();
+ }
+
// Flag to track if there are any errors
var hasErrors = false;
diff --git a/resources/views/themes/default1/client/layout/client.blade.php b/resources/views/themes/default1/client/layout/client.blade.php
index 0d1c15fe15..5c9d8e9462 100644
--- a/resources/views/themes/default1/client/layout/client.blade.php
+++ b/resources/views/themes/default1/client/layout/client.blade.php
@@ -160,7 +160,11 @@
- where('visibility', '1')->get();
+ role == 'user')
+ $pages = App\Model\kb\Page::where('status', '1')->where('visibility', '1')->get();
+ else
+ $pages = App\Model\kb\Page::where('status', '1')->get();
?>
@if(count($pages))