Unverified Commit 811f969a authored by Viral Solani's avatar Viral Solani Committed by GitHub

Merge pull request #246 from viralsolani/develop

Merge Develop to master
parents dafb3a3a e38cf422
......@@ -54,6 +54,9 @@ Generate a new application key
php artisan key:generate
Generate a new JWT secret key (If you want to use API)
php artisan jwt:secret
Generate a new JWT authentication secret key
php artisan jwt:secret
......
<?php
Breadcrumbs::register('admin.blogcategories.index', function ($breadcrumbs) {
Breadcrumbs::register('admin.blogCategories.index', function ($breadcrumbs) {
$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->parent('admin.blogcategories.index');
$breadcrumbs->push(trans('menus.backend.blogcategories.create'), route('admin.blogcategories.create'));
Breadcrumbs::register('admin.blogCategories.create', function ($breadcrumbs) {
$breadcrumbs->parent('admin.blogCategories.index');
$breadcrumbs->push(trans('menus.backend.blogcategories.create'), route('admin.blogCategories.create'));
});
Breadcrumbs::register('admin.blogcategories.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.blogcategories.index');
$breadcrumbs->push(trans('menus.backend.blogcategories.edit'), route('admin.blogcategories.edit', $id));
Breadcrumbs::register('admin.blogCategories.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.blogCategories.index');
$breadcrumbs->push(trans('menus.backend.blogcategories.edit'), route('admin.blogCategories.edit', $id));
});
<?php
Breadcrumbs::register('admin.blogtags.index', function ($breadcrumbs) {
Breadcrumbs::register('admin.blogTags.index', function ($breadcrumbs) {
$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->parent('admin.blogtags.index');
$breadcrumbs->push(trans('menus.backend.blogtags.create'), route('admin.blogtags.create'));
Breadcrumbs::register('admin.blogTags.create', function ($breadcrumbs) {
$breadcrumbs->parent('admin.blogTags.index');
$breadcrumbs->push(trans('menus.backend.blogtags.create'), route('admin.blogTags.create'));
});
Breadcrumbs::register('admin.blogtags.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.blogtags.index');
$breadcrumbs->push(trans('menus.backend.blogtags.edit'), route('admin.blogtags.edit', $id));
Breadcrumbs::register('admin.blogTags.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.blogTags.index');
$breadcrumbs->push(trans('menus.backend.blogtags.edit'), route('admin.blogTags.edit', $id));
});
......@@ -32,9 +32,11 @@ class BlogCategoriesController extends APIController
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return BlogCategoriesResource::collection(
$this->repository->getForDataTable()->paginate($limit)
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
......
......@@ -30,9 +30,11 @@ class BlogTagsController extends APIController
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return BlogTagsResource::collection(
$this->repository->getForDataTable()->paginate($limit)
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
......
......@@ -30,9 +30,11 @@ class BlogsController extends APIController
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return BlogsResource::collection(
$this->repository->getForDataTable()->paginate($limit)
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
......
......@@ -30,9 +30,11 @@ class DeactivatedUsersController extends APIController
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return UserResource::collection(
$this->repository->getForDataTable(0, false)->paginate($limit)
$this->repository->getForDataTable(0, false)->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
}
......@@ -30,9 +30,11 @@ class DeletedUsersController extends APIController
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return UserResource::collection(
$this->repository->getForDataTable(0, true)->paginate($limit)
$this->repository->getForDataTable(0, true)->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
}
......@@ -30,9 +30,11 @@ class FaqsController extends APIController
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return FaqsResource::collection(
$this->repository->getForDataTable()->paginate($limit)
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
......
......@@ -30,9 +30,11 @@ class PagesController extends APIController
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return PagesResource::collection(
$this->repository->getForDataTable()->paginate($limit)
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
......
......@@ -32,9 +32,11 @@ class PermissionController extends APIController
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return PermissionResource::collection(
$this->repository->getForDataTable()->paginate($limit)
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
......@@ -104,6 +106,7 @@ class PermissionController extends APIController
$this->repository->delete($permission);
return $this->respond([
'data' => $permission->id,
'message' => trans('alerts.backend.permissions.deleted'),
]);
}
......
......@@ -32,9 +32,11 @@ class RolesController extends APIController
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return RoleResource::collection(
$this->repository->getForDataTable()->paginate($limit)
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
......@@ -60,6 +62,7 @@ class RolesController extends APIController
public function store(Request $request)
{
$validation = $this->validateRole($request);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
......@@ -105,6 +108,7 @@ class RolesController extends APIController
$this->repository->delete($role);
return $this->respond([
'data' => $role->id,
'message' => trans('alerts.backend.roles.deleted'),
]);
}
......
......@@ -32,9 +32,11 @@ class UsersController extends APIController
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return UserResource::collection(
$this->repository->getForDataTable(1, false)->paginate($limit)
$this->repository->getForDataTable(1, false)->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
......@@ -106,6 +108,7 @@ class UsersController extends APIController
$this->repository->delete($user);
return $this->respond([
'data' => $user->id,
'message' => trans('alerts.backend.users.deleted'),
]);
}
......
......@@ -9,6 +9,7 @@ use App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\ManageBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\StoreBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\UpdateBlogCategoriesRequest;
use App\Http\Responses\Backend\BlogCategory\EditResponse;
use App\Http\Responses\RedirectResponse;
use App\Http\Responses\ViewResponse;
use App\Models\BlogCategories\BlogCategory;
......@@ -65,7 +66,7 @@ class BlogCategoriesController extends Controller
* @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param \App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest $request
*
* @return mixed
* @return \App\Http\Responses\Backend\BlogCategory\EditResponse
*/
public function edit(BlogCategory $blogCategory, EditBlogCategoriesRequest $request)
{
......
......@@ -22,14 +22,6 @@ class FrontendController extends Controller
return view('frontend.index', compact('google_analytics', $google_analytics));
}
/**
* @return \Illuminate\View\View
*/
public function macros()
{
return view('frontend.macros');
}
/**
* show page by $page_slug.
*/
......
<?php
namespace App\Http\Middleware;
use Closure;
use JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException;
class VerifyJWTToken
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
try {
$user = JWTAuth::parseToken()->authenticate();
} catch (JWTException $e) {
if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException) {
return response()->json(['token_expired'], $e->getStatusCode());
} elseif ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) {
return response()->json(['token_invalid'], $e->getStatusCode());
} else {
return response()->json(['error' => 'Token is required']);
}
}
return $next($request);
}
}
......@@ -27,7 +27,7 @@ class UpdateBlogCategoriesRequest extends Request
public function rules()
{
return [
'name' => 'required|max:191',
'name' => 'required|max:191|unique:blog_categories,name,'.$this->segment(3),
];
}
......@@ -39,6 +39,7 @@ class UpdateBlogCategoriesRequest extends Request
public function messages()
{
return [
'name.unique' => 'Blog category name already exists, please enter a different name.',
'name.required' => 'Blog category name must required',
'name.max' => 'Blog category may not be greater than 191 characters.',
];
......
......@@ -27,7 +27,7 @@ class UpdateBlogTagsRequest extends Request
public function rules()
{
return [
'name' => 'required|max:191',
'name' => 'required|max:191|unique:blog_tags,name,'.$this->segment(3),
];
}
......@@ -39,6 +39,7 @@ class UpdateBlogTagsRequest extends Request
public function messages()
{
return [
'name.unique' => 'Blog Tag name already exists, please enter a different name.',
'name.required' => 'Blog Tag name is a required field.',
'name.max' => 'Blog Tag may not be greater than 191 characters.',
];
......
......@@ -27,7 +27,7 @@ class UpdateBlogsRequest extends Request
public function rules()
{
return [
'name' => 'required|max:191',
'name' => 'required|max:191|unique:blogs,name,'.$this->segment(3),
'content' => 'required',
'categories' => 'required',
'tags' => 'required',
......@@ -42,6 +42,7 @@ class UpdateBlogsRequest extends Request
public function messages()
{
return [
'name.unique' => 'Blog name already exists, please enter a different name.',
'name.required' => 'Please insert Blog Title',
'name.max' => 'Blog Title may not be greater than 191 characters.',
];
......
......@@ -18,8 +18,8 @@ class RoleResource extends Resource
return [
'id' => $this->id,
'name' => $this->name,
'permission' => ($this->all) ? 'All' : optional($this->permissions)->pluck('display_name'),
'noofuses' => $this->users->count(),
'permissions' => ($this->all) ? 'All' : optional($this->permissions)->pluck('display_name'),
'number_of_users' => $this->users->count(),
'sort' => $this->sort,
'status' => $this->status,
'registered_at' => $this->created_at->toIso8601String(),
......
......@@ -25,8 +25,8 @@ class UserResource extends Resource
'role' => optional($this->roles()->first())->name,
'permissions' => $this->permissions()->get(),
'status' => $this->status,
'registered_at' => $this->created_at->toIso8601String(),
'last_updated_at' => $this->updated_at->toIso8601String(),
'created_at' => $this->created_at->toIso8601String(),
'updated_at' => $this->updated_at->toIso8601String(),
];
}
}
<?php
namespace App\Http\Responses\Backend\Menu;
namespace App\Http\Responses\Backend\BlogCategory;
use Illuminate\Contracts\Support\Responsable;
......@@ -14,7 +14,7 @@ class EditResponse implements Responsable
/**
* @param \App\Models\BlogCategories\BlogCategory $blogCategory
*/
public function __construct($blogCategory, $types, $modules)
public function __construct($blogCategory)
{
$this->blogCategory = $blogCategory;
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -10,7 +10,7 @@
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.17",
"axios": "^0.18",
"bootstrap-sass": "^3.3.7",
"cross-env": "^5.1",
"font-awesome": "^4.7.0",
......@@ -27,6 +27,7 @@
"datatables.net-buttons": "^1.3.1",
"moment": "^2.18.1",
"nestable2": "^1.5.0",
"node-sass": "^4.9.0",
"pluralize": "^7.0.0",
"select2": "^4.0.4",
"tinymce": "^4.5.8"
......
......@@ -743,7 +743,7 @@ function _init() {
* 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'));
const app = new Vue({
......
......@@ -29,6 +29,11 @@ export default {
methods: {
flash(message, type) {
if (! type) {
type = "info";
}
this.body = message;
this.typeClass = "alert alert-" + type;
this.show = true;
......
......@@ -13,6 +13,7 @@ require('../bootstrap');
* 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'));
const app = new Vue({
......
......@@ -17,7 +17,7 @@
<h3 class="box-title">{{ trans('labels.backend.faqs.create') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.faqs-header-buttons')
@include('backend.faqs.partials.faqs-header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
......
......@@ -17,7 +17,7 @@
<h3 class="box-title">{{ trans('labels.backend.faqs.edit') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.faqs-header-buttons')
@include('backend.faqs.partials.faqs-header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
......
......@@ -36,9 +36,7 @@
<!-- Scripts -->
<script>
window.Laravel = <?php echo json_encode([
'csrfToken' => csrf_token(),
]); ?>
window.Laravel = {!! json_encode([ 'csrfToken' => csrf_token() ]) !!};
</script>
</head>
<body class="skin-{{ config('backend.theme') }} {{ config('backend.layout') }}">
......
......@@ -16,9 +16,9 @@
</div><!--navbar-header-->
<div class="collapse navbar-collapse" id="frontend-navbar-collapse">
<ul class="nav navbar-nav">
<li>{{ link_to_route('frontend.macros', trans('navs.frontend.macros')) }}</li>
</ul>
{{-- <ul class="nav navbar-nav">
<li></li>
</ul> --}}
<ul class="nav navbar-nav navbar-right">
@if (config('locale.status') && count(config('locale.languages')) > 1)
<li class="dropdown">
......
@extends('frontend.layouts.app')
@section('content')
<div class="row">
<div class="col-xs-12">
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-home"></i> {{ trans('labels.frontend.macros.macro_examples') }}</div>
<div class="panel-body">
<div class="form-group">
<label>{{ trans('labels.frontend.macros.state.us.us') }}</label>
{{-- Shorthand for this is just selectState, set which version is shorthanded in Macros/Dropdowns --}}
{{ Form::selectStateUS('state', 'NY', ['class' => 'form-control']) }}
</div>
<div class="form-group">
<label>{{ trans('labels.frontend.macros.state.us.outlying') }}</label>
{{ Form::selectStateUSOutlyingTerritories('state_outlying', null, ['class' => 'form-control']) }}
</div>
<div class="form-group">
<label>{{ trans('labels.frontend.macros.state.us.armed') }}</label>
{{ Form::selectStateUSArmedForces('armed_forces', null, ['class' => 'form-control']) }}
</div>
<div class="form-group">
<label>{{ trans('labels.frontend.macros.territories.canada') }}</label>
{{ Form::selectCanadaTerritories('canada_territories', null, ['class' => 'form-control']) }}
</div>
<div class="form-group">
<label>{{ trans('labels.frontend.macros.state.mexico') }}</label>
{{ Form::selectStateMexico('mexico', null, ['class' => 'form-control']) }}
</div>
<div class="form-group">
<label>{{ trans('labels.frontend.macros.country.alpha') }}</label>
{{ Form::selectCountryAlpha('country_alpha', 'ISO 3166-2:US', ['class' => 'form-control']) }}
</div>
<div class="form-group">
<label>{{ trans('labels.frontend.macros.country.alpha2') }}</label>
{{-- Shorthand for this is just selectCountry, set which version is shorthanded in Macros/Dropdowns --}}
{{ Form::selectCountryAlpha2('country_alpha2', 'US', ['class' => 'form-control']) }}
</div>
<div class="form-group">
<label>{{ trans('labels.frontend.macros.country.alpha3') }}</label>
{{ Form::selectCountryAlpha3('country_alpha3', 'USA', ['class' => 'form-control']) }}
</div>
<div class="form-group">
<label>{{ trans('labels.frontend.macros.country.numeric') }}</label>
{{ Form::selectCountryNumeric('country_numeric', '840', ['class' => 'form-control']) }}
</div>
<div class="form-group">
<label>{{ trans('labels.frontend.macros.timezone') }}</label>
{{ Form::selectTimezone('timezone', 'America/New_York', ['class' => 'form-control']) }}
</div>
</div>
</div><!-- panel -->
</div><!-- col-md-10 -->
</div><!-- row -->
@endsection
\ No newline at end of file
......@@ -5,7 +5,6 @@
* All route names are prefixed with 'frontend.'.
*/
Route::get('/', 'FrontendController@index')->name('index');
Route::get('macros', 'FrontendController@macros')->name('macros');
Route::post('/get/states', 'FrontendController@getStates')->name('get.states');
Route::post('/get/cities', 'FrontendController@getCities')->name('get.cities');
......
......@@ -76,4 +76,17 @@ class ManageBlogCategoriesTest extends TestCase
$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
$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
$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