Unverified Commit 58f57b3b authored by Vipul Basapati's avatar Vipul Basapati Committed by GitHub

Merge pull request #238 from bvipul/develop

Solved Issues
parents d05f4a53 e1d3cfc8
<?php <?php
Breadcrumbs::register('admin.blogcategories.index', function ($breadcrumbs) { Breadcrumbs::register('admin.blogCategories.index', function ($breadcrumbs) {
$breadcrumbs->parent('admin.dashboard'); $breadcrumbs->parent('admin.dashboard');
$breadcrumbs->push(trans('menus.backend.blogcategories.management'), route('admin.blogcategories.index')); $breadcrumbs->push(trans('menus.backend.blogcategories.management'), route('admin.blogCategories.index'));
}); });
Breadcrumbs::register('admin.blogcategories.create', function ($breadcrumbs) { Breadcrumbs::register('admin.blogCategories.create', function ($breadcrumbs) {
$breadcrumbs->parent('admin.blogcategories.index'); $breadcrumbs->parent('admin.blogCategories.index');
$breadcrumbs->push(trans('menus.backend.blogcategories.create'), route('admin.blogcategories.create')); $breadcrumbs->push(trans('menus.backend.blogcategories.create'), route('admin.blogCategories.create'));
}); });
Breadcrumbs::register('admin.blogcategories.edit', function ($breadcrumbs, $id) { Breadcrumbs::register('admin.blogCategories.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.blogcategories.index'); $breadcrumbs->parent('admin.blogCategories.index');
$breadcrumbs->push(trans('menus.backend.blogcategories.edit'), route('admin.blogcategories.edit', $id)); $breadcrumbs->push(trans('menus.backend.blogcategories.edit'), route('admin.blogCategories.edit', $id));
}); });
<?php <?php
Breadcrumbs::register('admin.blogtags.index', function ($breadcrumbs) { Breadcrumbs::register('admin.blogTags.index', function ($breadcrumbs) {
$breadcrumbs->parent('admin.dashboard'); $breadcrumbs->parent('admin.dashboard');
$breadcrumbs->push(trans('menus.backend.blogtags.management'), route('admin.blogtags.index')); $breadcrumbs->push(trans('menus.backend.blogtags.management'), route('admin.blogTags.index'));
}); });
Breadcrumbs::register('admin.blogtags.create', function ($breadcrumbs) { Breadcrumbs::register('admin.blogTags.create', function ($breadcrumbs) {
$breadcrumbs->parent('admin.blogtags.index'); $breadcrumbs->parent('admin.blogTags.index');
$breadcrumbs->push(trans('menus.backend.blogtags.create'), route('admin.blogtags.create')); $breadcrumbs->push(trans('menus.backend.blogtags.create'), route('admin.blogTags.create'));
}); });
Breadcrumbs::register('admin.blogtags.edit', function ($breadcrumbs, $id) { Breadcrumbs::register('admin.blogTags.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.blogtags.index'); $breadcrumbs->parent('admin.blogTags.index');
$breadcrumbs->push(trans('menus.backend.blogtags.edit'), route('admin.blogtags.edit', $id)); $breadcrumbs->push(trans('menus.backend.blogtags.edit'), route('admin.blogTags.edit', $id));
}); });
...@@ -3,16 +3,17 @@ ...@@ -3,16 +3,17 @@
namespace App\Http\Controllers\Backend\BlogCategories; namespace App\Http\Controllers\Backend\BlogCategories;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Responses\ViewResponse;
use App\Http\Responses\RedirectResponse;
use App\Models\BlogCategories\BlogCategory;
use App\Http\Responses\Backend\BlogCategory\EditResponse;
use App\Repositories\Backend\BlogCategories\BlogCategoriesRepository;
use App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\StoreBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\CreateBlogCategoriesRequest; use App\Http\Requests\Backend\BlogCategories\CreateBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\DeleteBlogCategoriesRequest; use App\Http\Requests\Backend\BlogCategories\DeleteBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\ManageBlogCategoriesRequest; use App\Http\Requests\Backend\BlogCategories\ManageBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\StoreBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\UpdateBlogCategoriesRequest; use App\Http\Requests\Backend\BlogCategories\UpdateBlogCategoriesRequest;
use App\Http\Responses\RedirectResponse;
use App\Http\Responses\ViewResponse;
use App\Models\BlogCategories\BlogCategory;
use App\Repositories\Backend\BlogCategories\BlogCategoriesRepository;
/** /**
* Class BlogCategoriesController. * Class BlogCategoriesController.
...@@ -65,7 +66,7 @@ class BlogCategoriesController extends Controller ...@@ -65,7 +66,7 @@ class BlogCategoriesController extends Controller
* @param \App\Models\BlogCategories\BlogCategory $blogCategory * @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param \App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest $request * @param \App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest $request
* *
* @return mixed * @return \App\Http\Responses\Backend\BlogCategory\EditResponse
*/ */
public function edit(BlogCategory $blogCategory, EditBlogCategoriesRequest $request) public function edit(BlogCategory $blogCategory, EditBlogCategoriesRequest $request)
{ {
......
...@@ -27,7 +27,7 @@ class UpdateBlogCategoriesRequest extends Request ...@@ -27,7 +27,7 @@ class UpdateBlogCategoriesRequest extends Request
public function rules() public function rules()
{ {
return [ return [
'name' => 'required|max:191', 'name' => 'required|max:191|unique:blog_categories,name,' . $this->segment(3)
]; ];
} }
...@@ -39,6 +39,7 @@ class UpdateBlogCategoriesRequest extends Request ...@@ -39,6 +39,7 @@ class UpdateBlogCategoriesRequest extends Request
public function messages() public function messages()
{ {
return [ return [
'name.unique' => 'Blog category name already exists, please enter a different name.',
'name.required' => 'Blog category name must required', 'name.required' => 'Blog category name must required',
'name.max' => 'Blog category may not be greater than 191 characters.', 'name.max' => 'Blog category may not be greater than 191 characters.',
]; ];
......
...@@ -27,7 +27,7 @@ class UpdateBlogTagsRequest extends Request ...@@ -27,7 +27,7 @@ class UpdateBlogTagsRequest extends Request
public function rules() public function rules()
{ {
return [ return [
'name' => 'required|max:191', 'name' => 'required|max:191|unique:blog_tags,name,' . $this->segment(3)
]; ];
} }
...@@ -39,6 +39,7 @@ class UpdateBlogTagsRequest extends Request ...@@ -39,6 +39,7 @@ class UpdateBlogTagsRequest extends Request
public function messages() public function messages()
{ {
return [ return [
'name.unique' => 'Blog Tag name already exists, please enter a different name.',
'name.required' => 'Blog Tag name is a required field.', 'name.required' => 'Blog Tag name is a required field.',
'name.max' => 'Blog Tag may not be greater than 191 characters.', 'name.max' => 'Blog Tag may not be greater than 191 characters.',
]; ];
......
...@@ -27,7 +27,7 @@ class UpdateBlogsRequest extends Request ...@@ -27,7 +27,7 @@ class UpdateBlogsRequest extends Request
public function rules() public function rules()
{ {
return [ return [
'name' => 'required|max:191', 'name' => 'required|max:191|unique:blogs,name,' . $this->segment(3),
'content' => 'required', 'content' => 'required',
'categories' => 'required', 'categories' => 'required',
'tags' => 'required', 'tags' => 'required',
...@@ -42,6 +42,7 @@ class UpdateBlogsRequest extends Request ...@@ -42,6 +42,7 @@ class UpdateBlogsRequest extends Request
public function messages() public function messages()
{ {
return [ return [
'name.unique' => 'Blog name already exists, please enter a different name.',
'name.required' => 'Please insert Blog Title', 'name.required' => 'Please insert Blog Title',
'name.max' => 'Blog Title may not be greater than 191 characters.', 'name.max' => 'Blog Title may not be greater than 191 characters.',
]; ];
......
<?php <?php
namespace App\Http\Responses\Backend\Menu; namespace App\Http\Responses\Backend\BlogCategory;
use Illuminate\Contracts\Support\Responsable; use Illuminate\Contracts\Support\Responsable;
...@@ -14,7 +14,7 @@ class EditResponse implements Responsable ...@@ -14,7 +14,7 @@ class EditResponse implements Responsable
/** /**
* @param \App\Models\BlogCategories\BlogCategory $blogCategory * @param \App\Models\BlogCategories\BlogCategory $blogCategory
*/ */
public function __construct($blogCategory, $types, $modules) public function __construct($blogCategory)
{ {
$this->blogCategory = $blogCategory; $this->blogCategory = $blogCategory;
} }
......
...@@ -743,7 +743,7 @@ function _init() { ...@@ -743,7 +743,7 @@ function _init() {
* or customize the JavaScript scaffolding to fit your unique needs. * or customize the JavaScript scaffolding to fit your unique needs.
*/ */
Vue.component('flash', require('../components/backend/Flash.vue')); Vue.component('flash', require('../components/Flash.vue'));
Vue.component('export-component', require('../components/backend/Export.vue')); Vue.component('export-component', require('../components/backend/Export.vue'));
const app = new Vue({ const app = new Vue({
......
...@@ -29,11 +29,16 @@ export default { ...@@ -29,11 +29,16 @@ export default {
methods: { methods: {
flash(message, type) { flash(message, type) {
this.body = message;
this.typeClass = "alert alert-" + type; if (! type) {
this.show = true; type = "info";
}
this.hide(); this.body = message;
this.typeClass = "alert alert-" + type;
this.show = true;
this.hide();
}, },
hide() { hide() {
......
...@@ -13,6 +13,7 @@ require('../bootstrap'); ...@@ -13,6 +13,7 @@ require('../bootstrap');
* or customize the JavaScript scaffolding to fit your unique needs. * or customize the JavaScript scaffolding to fit your unique needs.
*/ */
Vue.component('flash', require('../components/Flash.vue'));
Vue.component('example', require('../components/frontend/Example.vue')); Vue.component('example', require('../components/frontend/Example.vue'));
const app = new Vue({ const app = new Vue({
......
...@@ -36,9 +36,7 @@ ...@@ -36,9 +36,7 @@
<!-- Scripts --> <!-- Scripts -->
<script> <script>
window.Laravel = <?php echo json_encode([ window.Laravel = {!! json_encode([ 'csrfToken' => csrf_token() ]) !!};
'csrfToken' => csrf_token(),
]); ?>
</script> </script>
</head> </head>
<body class="skin-{{ config('backend.theme') }} {{ config('backend.layout') }}"> <body class="skin-{{ config('backend.theme') }} {{ config('backend.layout') }}">
......
...@@ -76,4 +76,17 @@ class ManageBlogCategoriesTest extends TestCase ...@@ -76,4 +76,17 @@ class ManageBlogCategoriesTest extends TestCase
$this->assertDatabaseMissing(config('module.blog_categories.table'), ['name' => $category->name, 'id' => $category->id, 'deleted_at' => null]); $this->assertDatabaseMissing(config('module.blog_categories.table'), ['name' => $category->name, 'id' => $category->id, 'deleted_at' => null]);
} }
/** @test */
public function a_user_can_not_update_a_blog_category_with_same_name()
{
$this->actingAs($this->admin)->withExceptionHandling();
$catCategory = create(BlogCategory::class, ['name' => 'Cat']);
$dogCategory = create(BlogCategory::class, ['name' => 'Dog']);
$this->patch(route('admin.blogCategories.update', $dogCategory),
['name' => 'Cat']
)->assertSessionHasErrors('name'); ;
}
} }
...@@ -76,4 +76,17 @@ class ManageBlogTagsTest extends TestCase ...@@ -76,4 +76,17 @@ class ManageBlogTagsTest extends TestCase
$this->assertDatabaseMissing(config('module.blog_tags.table'), ['name' => $tag->name, 'id' => $tag->id, 'deleted_at' => null]); $this->assertDatabaseMissing(config('module.blog_tags.table'), ['name' => $tag->name, 'id' => $tag->id, 'deleted_at' => null]);
} }
/** @test */
public function a_user_can_not_update_a_blog_tag_with_same_name()
{
$this->actingAs($this->admin)->withExceptionHandling();
$catTag = create(BlogTag::class, ['name' => 'Cat']);
$dogTag = create(BlogTag::class, ['name' => 'Dog']);
$this->patch(route('admin.blogTags.update', $dogTag),
['name' => 'Cat']
)->assertSessionHasErrors('name');
}
} }
...@@ -196,4 +196,17 @@ class ManageBlogsTest extends TestCase ...@@ -196,4 +196,17 @@ class ManageBlogsTest extends TestCase
$this->assertDatabaseMissing(config('module.blogs.table'), ['id' => $this->blog->id, 'deleted_at' => null]); $this->assertDatabaseMissing(config('module.blogs.table'), ['id' => $this->blog->id, 'deleted_at' => null]);
} }
/** @test */
public function a_user_can_not_update_a_blog_with_same_name()
{
$this->actingAs($this->admin)->withExceptionHandling();
$catCategory = create(Blog::class, ['name' => 'Cat']);
$dogCategory = create(Blog::class, ['name' => 'Dog']);
$this->patch(route('admin.blogs.update', $dogCategory),
['name' => 'Cat']
)->assertSessionHasErrors('name'); ;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment