Commit a0f1a12f authored by Vipul Basapati's avatar Vipul Basapati

Merge branch 'master' of https://github.com/viralsolani/laravel-adminpanel into develop

parents f7336639 23cc26ba
...@@ -93,7 +93,7 @@ You can now access the server at http://localhost:8000 ...@@ -93,7 +93,7 @@ You can now access the server at http://localhost:8000
npm install npm install
npm run development npm run development
php artisan key:generate php artisan key:generate
php artisan jwt:generate php artisan jwt:secret
php artisan vendor:publish --tag=lfm_public php artisan vendor:publish --tag=lfm_public
## Logging In ## Logging In
...@@ -122,7 +122,7 @@ Password: `1234` ...@@ -122,7 +122,7 @@ Password: `1234`
If you come across any issues please report them [here](https://github.com/viralsolani/laravel-adminpanel/issues). If you come across any issues please report them [here](https://github.com/viralsolani/laravel-adminpanel/issues).
## Contributing ## Contributing
Feel free to create any pull requests for the project. For propsing any new changes or features you want to add to the project, you can send us an email at viral.solani@gmail.com or basapativipulkumar@gmail.com. Feel free to create any pull requests for the project. For proposing any new changes or features you want to add to the project, you can send us an email at viral.solani@gmail.com or basapativipulkumar@gmail.com.
## License ## License
......
...@@ -3,9 +3,15 @@ ...@@ -3,9 +3,15 @@
namespace App\Exceptions; namespace App\Exceptions;
use Exception; use Exception;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Auth\AuthenticationException; use Illuminate\Auth\AuthenticationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Session\TokenMismatchException; use Illuminate\Session\TokenMismatchException;
use Illuminate\Validation\ValidationException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
{ {
...@@ -47,6 +53,53 @@ class Handler extends ExceptionHandler ...@@ -47,6 +53,53 @@ class Handler extends ExceptionHandler
*/ */
public function render($request, Exception $exception) public function render($request, Exception $exception)
{ {
//dd($exception);
if (strpos($request->url(), '/api/') !== false) {
\Log::debug('API Request Exception - '.$request->url().' - '.$exception->getMessage().(!empty($request->all()) ? ' - '.json_encode($request->except(['password'])) : ''));
if ($exception instanceof AuthorizationException) {
return $this->setStatusCode(403)->respondWithError($exception->getMessage());
}
if ($exception instanceof MethodNotAllowedHttpException) {
return $this->setStatusCode(403)->respondWithError('Please check HTTP Request Method. - MethodNotAllowedHttpException');
}
if ($exception instanceof NotFoundHttpException) {
return $this->setStatusCode(403)->respondWithError('Please check your URL to make sure request is formatted properly. - NotFoundHttpException');
}
if ($exception instanceof GeneralException) {
return $this->setStatusCode(403)->respondWithError($exception->getMessage());
}
if ($exception instanceof ModelNotFoundException) {
return $this->setStatusCode(403)->respondWithError('Item could not be found. Please check identifier.');
}
if ($exception instanceof ValidationException) {
\Log::debug('API Validation Exception - '.json_encode($exception->validator->messages()));
return $this->setStatusCode(422)->respondWithError($exception->validator->messages());
}
/*
* Redirect if token mismatch error
* Usually because user stayed on the same screen too long and their session expired
*/
if ($exception instanceof UnauthorizedHttpException) {
switch (get_class($exception->getPrevious())) {
case \App\Exceptions\Handler::class:
return $this->setStatusCode($exception->getStatusCode())->respondWithError('Token has not been provided.');
case \Tymon\JWTAuth\Exceptions\TokenExpiredException::class:
return $this->setStatusCode($exception->getStatusCode())->respondWithError('Token has expired.');
case \Tymon\JWTAuth\Exceptions\TokenInvalidException::class:
case \Tymon\JWTAuth\Exceptions\TokenBlacklistedException::class:
return $this->setStatusCode($exception->getStatusCode())->respondWithError('Token is invalid.');
}
}
}
/* /*
* Redirect if token mismatch error * Redirect if token mismatch error
* Usually because user stayed on the same screen too long and their session expired * Usually because user stayed on the same screen too long and their session expired
...@@ -81,4 +134,58 @@ class Handler extends ExceptionHandler ...@@ -81,4 +134,58 @@ class Handler extends ExceptionHandler
return redirect()->guest(route('frontend.auth.login')); return redirect()->guest(route('frontend.auth.login'));
} }
/**
* get the status code.
*
* @return statuscode
*/
public function getStatusCode()
{
return $this->statusCode;
}
/**
* set the status code.
*
* @param [type] $statusCode [description]
*
* @return statuscode
*/
public function setStatusCode($statusCode)
{
$this->statusCode = $statusCode;
return $this;
}
/**
* respond with error.
*
* @param $message
*
* @return \Illuminate\Http\JsonResponse
*/
protected function respondWithError($message)
{
return $this->respond([
'error' => [
'message' => $message,
'status_code' => $this->getStatusCode(),
],
]);
}
/**
* Respond.
*
* @param array $data
* @param array $headers
*
* @return \Illuminate\Http\JsonResponse
*/
public function respond($data, $headers = [])
{
return response()->json($data, $this->getStatusCode(), $headers);
}
} }
...@@ -178,7 +178,7 @@ class APIController extends Controller ...@@ -178,7 +178,7 @@ class APIController extends Controller
return $this->setStatusCode(204)->respond(null); return $this->setStatusCode(204)->respond(null);
} }
/** /**Note this function is same as the below function but instead of responding with error below function returns error json
* Throw Validation. * Throw Validation.
* *
* @param string $message * @param string $message
...@@ -188,6 +188,6 @@ class APIController extends Controller ...@@ -188,6 +188,6 @@ class APIController extends Controller
public function throwValidation($message) public function throwValidation($message)
{ {
return $this->setStatusCode(422) return $this->setStatusCode(422)
->respondWithError($message); ->respondWithError($message);
} }
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api\V1; namespace App\Http\Controllers\Api\V1;
use App\Models\Access\User\User;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use JWTAuth; use JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException; use Tymon\JWTAuth\Exceptions\JWTException;
......
...@@ -23,9 +23,11 @@ class BlogCategoriesController extends APIController ...@@ -23,9 +23,11 @@ class BlogCategoriesController extends APIController
} }
/** /**
* Return the users. * Return the blog-categories.
* *
* @return \Illuminate\Http\Response * @param Request $request
*
*@return \Illuminate\Http\JsonResponse
*/ */
public function index(Request $request) public function index(Request $request)
{ {
...@@ -39,9 +41,9 @@ class BlogCategoriesController extends APIController ...@@ -39,9 +41,9 @@ class BlogCategoriesController extends APIController
/** /**
* Return the specified resource. * Return the specified resource.
* *
* @param User $user * @param BlogCategory $blog_category
* *
* @return \Illuminate\Http\Response *@return \Illuminate\Http\JsonResponse
*/ */
public function show(BlogCategory $blog_category) public function show(BlogCategory $blog_category)
{ {
...@@ -53,11 +55,11 @@ class BlogCategoriesController extends APIController ...@@ -53,11 +55,11 @@ class BlogCategoriesController extends APIController
* *
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Http\Response *@return \Illuminate\Http\JsonResponse
*/ */
public function store(Request $request) public function store(Request $request)
{ {
$validation = $this->validatingRequest($request); $validation = $this->validateBlogCategory($request);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
} }
...@@ -68,14 +70,14 @@ class BlogCategoriesController extends APIController ...@@ -68,14 +70,14 @@ class BlogCategoriesController extends APIController
} }
/** /**
* @param BlogCategory $blog_category * @param BlogCategory $blog_category
* @param UpdateBlogCategoryRequest $request * @param Request $request
* *
* @return mixed * @return mixed
*/ */
public function update(Request $request, BlogCategory $blog_category) public function update(Request $request, BlogCategory $blog_category)
{ {
$validation = $this->validatingRequest($request); $validation = $this->validateBlogCategory($request);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
...@@ -88,25 +90,34 @@ class BlogCategoriesController extends APIController ...@@ -88,25 +90,34 @@ class BlogCategoriesController extends APIController
return new BlogCategoriesResource($blog_category); return new BlogCategoriesResource($blog_category);
} }
public function validatingRequest(Request $request) /**
* @param BlogCategory $blog_category
* @param Request $request
*
* @return mixed
*/
public function destroy(BlogCategory $blog_category, Request $request)
{ {
$validation = Validator::make($request->all(), [ $this->repository->delete($blog_category);
'name' => 'required|max:191',
]);
return $validation; return $this->respond([
'message' => trans('alerts.backend.blogcategories.deleted'),
]);
} }
/** /**
* @param BlogCategory $blog_category * validateUser BlogCategory Requests.
* @param DeleteBlogCategoryRequest $request
* *
* @return mixed * @param Request $request
*
* @return Validator object
*/ */
public function destroy(BlogCategory $blog_category, Request $request) public function validateBlogCategory(Request $request)
{ {
$this->repository->delete($blog_category); $validation = Validator::make($request->all(), [
'name' => 'required|max:191',
]);
return ['message'=>'success']; return $validation;
} }
} }
...@@ -23,9 +23,9 @@ class BlogTagsController extends APIController ...@@ -23,9 +23,9 @@ class BlogTagsController extends APIController
} }
/** /**
* Return the users. * Return the BlogTags.
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function index(Request $request) public function index(Request $request)
{ {
...@@ -39,9 +39,9 @@ class BlogTagsController extends APIController ...@@ -39,9 +39,9 @@ class BlogTagsController extends APIController
/** /**
* Return the specified resource. * Return the specified resource.
* *
* @param User $user * @param BlogTag $blog_tag
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function show(BlogTag $blog_tag) public function show(BlogTag $blog_tag)
{ {
...@@ -53,7 +53,7 @@ class BlogTagsController extends APIController ...@@ -53,7 +53,7 @@ class BlogTagsController extends APIController
* *
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function store(Request $request) public function store(Request $request)
{ {
...@@ -68,17 +68,19 @@ class BlogTagsController extends APIController ...@@ -68,17 +68,19 @@ class BlogTagsController extends APIController
} }
/** /**
* @param BlogTag $blog_tag * Update BlogTag.
* @param UpdateBlogTagRequest $request *
* @param BlogTag $blog_tag
* @param Request $request
* *
* @return mixed * @return \Illuminate\Http\JsonResponse
*/ */
public function update(Request $request, BlogTag $blog_tag) public function update(Request $request, BlogTag $blog_tag)
{ {
$validation = $this->validatingRequest($request, $blog_tag->id); $validation = $this->validatingRequest($request, $blog_tag->id);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation);
} }
$this->repository->update($blog_tag, $request->all()); $this->repository->update($blog_tag, $request->all());
...@@ -88,20 +90,13 @@ class BlogTagsController extends APIController ...@@ -88,20 +90,13 @@ class BlogTagsController extends APIController
return new BlogTagsResource($blog_tag); return new BlogTagsResource($blog_tag);
} }
public function validatingRequest(Request $request, $id = 0)
{
$validation = Validator::make($request->all(), [
'name' => 'required|max:191|unique:blog_tags,name,'.$id,
]);
return $validation;
}
/** /**
* Delete BlogTag.
*
* @param BlogTag $blog_tag * @param BlogTag $blog_tag
* @param DeleteBlogTagRequest $request * @param DeleteBlogTagRequest $request
* *
* @return mixed * @return \Illuminate\Http\JsonResponse
*/ */
public function destroy(BlogTag $blog_tag, Request $request) public function destroy(BlogTag $blog_tag, Request $request)
{ {
...@@ -109,4 +104,20 @@ class BlogTagsController extends APIController ...@@ -109,4 +104,20 @@ class BlogTagsController extends APIController
return ['message'=>'success']; return ['message'=>'success'];
} }
/**
* validate BlogTag.
*
* @param $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function validatingRequest(Request $request, $id = 0)
{
$validation = Validator::make($request->all(), [
'name' => 'required|max:191|unique:blog_tags,name,'.$id,
]);
return $validation;
}
} }
...@@ -23,9 +23,9 @@ class BlogsController extends APIController ...@@ -23,9 +23,9 @@ class BlogsController extends APIController
} }
/** /**
* Return the users. * Return the blogs.
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function index(Request $request) public function index(Request $request)
{ {
...@@ -39,9 +39,9 @@ class BlogsController extends APIController ...@@ -39,9 +39,9 @@ class BlogsController extends APIController
/** /**
* Return the specified resource. * Return the specified resource.
* *
* @param User $user * @param Blog blog
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function show(Blog $blog) public function show(Blog $blog)
{ {
...@@ -53,11 +53,12 @@ class BlogsController extends APIController ...@@ -53,11 +53,12 @@ class BlogsController extends APIController
* *
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function store(Request $request) public function store(Request $request)
{ {
$validation = $this->validatingRequest($request); $validation = $this->validateBlog($request);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
} }
...@@ -68,14 +69,16 @@ class BlogsController extends APIController ...@@ -68,14 +69,16 @@ class BlogsController extends APIController
} }
/** /**
* @param Blog $blog * Update blog.
* @param UpdateBlogRequest $request *
* @param Blog $blog
* @param Request $request
* *
* @return mixed * @return \Illuminate\Http\JsonResponse
*/ */
public function update(Request $request, Blog $blog) public function update(Request $request, Blog $blog)
{ {
$validation = $this->validatingRequest($request, 'update'); $validation = $this->validateBlog($request, 'update');
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
...@@ -88,9 +91,33 @@ class BlogsController extends APIController ...@@ -88,9 +91,33 @@ class BlogsController extends APIController
return new BlogsResource($blog); return new BlogsResource($blog);
} }
public function validatingRequest(Request $request, $type = 'insert') /**
* Delete Blog.
*
* @param Blog $blog
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function destroy(Blog $blog, Request $request)
{ {
$featured_image = ($type == 'insert') ? 'required' : ''; $this->repository->delete($blog);
return $this->respond([
'message' => trans('alerts.backend.blogs.deleted'),
]);
}
/**
* validate Blog.
*
* @param $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function validateBlog(Request $request, $action = 'insert')
{
$featured_image = ($action == 'insert') ? 'required' : '';
$validation = Validator::make($request->all(), [ $validation = Validator::make($request->all(), [
'name' => 'required|max:191', 'name' => 'required|max:191',
...@@ -103,6 +130,11 @@ class BlogsController extends APIController ...@@ -103,6 +130,11 @@ class BlogsController extends APIController
return $validation; return $validation;
} }
/**
* validate message for validate blog.
*
* @return \Illuminate\Http\JsonResponse
*/
public function messages() public function messages()
{ {
return [ return [
...@@ -110,17 +142,4 @@ class BlogsController extends APIController ...@@ -110,17 +142,4 @@ class BlogsController extends APIController
'name.max' => 'Blog Title may not be greater than 191 characters.', 'name.max' => 'Blog Title may not be greater than 191 characters.',
]; ];
} }
/**
* @param Blog $blog
* @param DeleteBlogRequest $request
*
* @return mixed
*/
public function destroy(Blog $blog, Request $request)
{
$this->repository->delete($blog);
return ['message'=>'success'];
}
} }
<?php
namespace App\Http\Controllers\Api\V1;
use App\Http\Resources\UserResource;
use App\Repositories\Backend\Access\User\UserRepository;
use Illuminate\Http\Request;
class DeactivatedUsersController extends APIController
{
protected $repository;
/**
* __construct.
*
* @param $repository
*/
public function __construct(UserRepository $repository)
{
$this->repository = $repository;
}
/**
* Return the deactivated users.
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
return UserResource::collection(
$this->repository->getForDataTable(0, false)->paginate($limit)
);
}
}
<?php
namespace App\Http\Controllers\Api\V1;
use App\Http\Resources\UserResource;
use App\Repositories\Backend\Access\User\UserRepository;
use Illuminate\Http\Request;
class DeletedUsersController extends APIController
{
protected $repository;
/**
* __construct.
*
* @param $repository
*/
public function __construct(UserRepository $repository)
{
$this->repository = $repository;
}
/**
* Return the deleted users.
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
return UserResource::collection(
$this->repository->getForDataTable(0, true)->paginate($limit)
);
}
}
...@@ -23,9 +23,9 @@ class FaqsController extends APIController ...@@ -23,9 +23,9 @@ class FaqsController extends APIController
} }
/** /**
* Return the users. * Return the faqs.
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function index(Request $request) public function index(Request $request)
{ {
...@@ -39,9 +39,9 @@ class FaqsController extends APIController ...@@ -39,9 +39,9 @@ class FaqsController extends APIController
/** /**
* Return the specified resource. * Return the specified resource.
* *
* @param User $user * @param Faq $faq
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function show(Faq $faq) public function show(Faq $faq)
{ {
...@@ -53,11 +53,11 @@ class FaqsController extends APIController ...@@ -53,11 +53,11 @@ class FaqsController extends APIController
* *
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function store(Request $request) public function store(Request $request)
{ {
$validation = $this->validatingRequest($request); $validation = $this->validateFaq($request);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
} }
...@@ -68,14 +68,16 @@ class FaqsController extends APIController ...@@ -68,14 +68,16 @@ class FaqsController extends APIController
} }
/** /**
* @param Faq $faq * Update Faq.
* @param UpdateFaqRequest $request
* *
* @return mixed * @param Faq $faq
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/ */
public function update(Request $request, Faq $faq) public function update(Request $request, Faq $faq)
{ {
$validation = $this->validatingRequest($request); $validation = $this->validateFaq($request);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
...@@ -88,26 +90,37 @@ class FaqsController extends APIController ...@@ -88,26 +90,37 @@ class FaqsController extends APIController
return new FaqsResource($faq); return new FaqsResource($faq);
} }
public function validatingRequest(Request $request) /**
* Delete Faq.
*
* @param Faq $faq
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function destroy(Faq $faq, Request $request)
{ {
$validation = Validator::make($request->all(), [ $this->repository->delete($faq);
'question' => 'required|max:191',
'answer' => 'required',
]);
return $validation; return $this->respond([
'message' => trans('alerts.backend.faqs.deleted'),
]);
} }
/** /**
* @param Faq $faq * validate Faq.
* @param DeleteFaqRequest $request
* *
* @return mixed * @param $request
*
* @return \Illuminate\Http\JsonResponse
*/ */
public function destroy(Faq $faq, Request $request) public function validateFaq(Request $request)
{ {
$this->repository->delete($faq); $validation = Validator::make($request->all(), [
'question' => 'required|max:191',
'answer' => 'required',
]);
return ['message'=>'success']; return $validation;
} }
} }
...@@ -23,9 +23,9 @@ class PagesController extends APIController ...@@ -23,9 +23,9 @@ class PagesController extends APIController
} }
/** /**
* Return the users. * Return the pages.
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function index(Request $request) public function index(Request $request)
{ {
...@@ -39,9 +39,9 @@ class PagesController extends APIController ...@@ -39,9 +39,9 @@ class PagesController extends APIController
/** /**
* Return the specified resource. * Return the specified resource.
* *
* @param User $user * @param Pages $page
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function show(Page $page) public function show(Page $page)
{ {
...@@ -49,15 +49,15 @@ class PagesController extends APIController ...@@ -49,15 +49,15 @@ class PagesController extends APIController
} }
/** /**
* Creates the Resourse for Page. * Creates the Resource for Page.
* *
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function store(Request $request) public function store(Request $request)
{ {
$validation = $this->validatingRequest($request); $validation = $this->validatePages($request);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
} }
...@@ -68,14 +68,16 @@ class PagesController extends APIController ...@@ -68,14 +68,16 @@ class PagesController extends APIController
} }
/** /**
* @param Page $page * Update Page.
* @param UpdatePageRequest $request *
* @param Page $page
* @param Request $request
* *
* @return mixed * @return \Illuminate\Http\JsonResponse
*/ */
public function update(Request $request, Page $page) public function update(Request $request, Page $page)
{ {
$validation = $this->validatingRequest($request); $validation = $this->validatePages($request, $page->id);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
...@@ -88,26 +90,38 @@ class PagesController extends APIController ...@@ -88,26 +90,38 @@ class PagesController extends APIController
return new PagesResource($page); return new PagesResource($page);
} }
public function validatingRequest(Request $request)
{
$validation = Validator::make($request->all(), [
'title' => 'required|max:191',
'description' => 'required',
]);
return $validation;
}
/** /**
* Delete Page.
*
* @param Page $page * @param Page $page
* @param DeletePageRequest $request * @param DeletePageRequest $request
* *
* @return mixed * @return \Illuminate\Http\JsonResponse
*/ */
public function destroy(Page $page, Request $request) public function destroy(Page $page, Request $request)
{ {
$this->repository->delete($page); $this->repository->delete($page);
return ['message'=>'success']; return $this->respond([
'message' => trans('alerts.backend.pages.deleted'),
]);
}
/**
* validateUser Pages Requests.
*
* @param Request $request
* @param int $id
*
* @return \Illuminate\Http\JsonResponse
*/
public function validatePages(Request $request, $id = 0)
{
$validation = Validator::make($request->all(), [
'title' => 'required|max:191|unique:pages,title,'.$id,
'description' => 'required',
]);
return $validation;
} }
} }
...@@ -23,25 +23,27 @@ class PermissionController extends APIController ...@@ -23,25 +23,27 @@ class PermissionController extends APIController
} }
/** /**
* Return the users. * Return the permissions.
* *
* @return \Illuminate\Http\Response * @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$limit = $request->get('paginate') ? $request->get('paginate') : 25; $limit = $request->get('paginate') ? $request->get('paginate') : 25;
return PermissionResource::collection( return PermissionResource::collection(
$this->repository->getPaginated($limit) $this->repository->getForDataTable()->paginate($limit)
); );
} }
/** /**
* Return the specified resource. * Return the specified resource.
* *
* @param User $user * @param Permission $permission
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function show(Permission $permission) public function show(Permission $permission)
{ {
...@@ -49,15 +51,15 @@ class PermissionController extends APIController ...@@ -49,15 +51,15 @@ class PermissionController extends APIController
} }
/** /**
* Creates the Resource for Role. * Creates the Resource for Permission.
* *
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function store(Request $request) public function store(Request $request)
{ {
$validation = $this->validatingRequest($request); $validation = $this->validatePermission($request);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
} }
...@@ -69,14 +71,14 @@ class PermissionController extends APIController ...@@ -69,14 +71,14 @@ class PermissionController extends APIController
} }
/** /**
* @param Role $role * @param Permission $permission
* @param UpdateRoleRequest $request * @param Request $request
* *
* @return mixed * @return \Illuminate\Http\JsonResponse
*/ */
public function update(Request $request, Permission $permission) public function update(Request $request, Permission $permission)
{ {
$validation = $this->validatingRequest($request); $validation = $this->validatePermission($request, $permission->id);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
...@@ -89,26 +91,38 @@ class PermissionController extends APIController ...@@ -89,26 +91,38 @@ class PermissionController extends APIController
return new PermissionResource($permission); return new PermissionResource($permission);
} }
public function validatingRequest(Request $request)
{
$validation = Validator::make($request->all(), [
'name' => 'required|max:191',
'display_name' => 'required|max:191',
]);
return $validation;
}
/** /**
* Delete permission.
*
* @param Role $role * @param Role $role
* @param DeleteRoleRequest $request * @param DeleteRoleRequest $request
* *
* @return mixed * @return \Illuminate\Http\JsonResponse
*/ */
public function destroy(Permission $permission, Request $request) public function destroy(Permission $permission, Request $request)
{ {
$this->repository->delete($permission); $this->repository->delete($permission);
return ['message'=>'success']; return $this->respond([
'message' => trans('alerts.backend.permissions.deleted'),
]);
}
/**
* validateUser Permission Requests.
*
* @param Request $request
* @param int $id
*
* @return Validator object
*/
public function validatePermission(Request $request, $id = 0)
{
$validation = Validator::make($request->all(), [
'name' => 'required|max:191|unique:permissions,name,'.$id,
'display_name' => 'required|max:191',
]);
return $validation;
} }
} }
...@@ -23,25 +23,27 @@ class RolesController extends APIController ...@@ -23,25 +23,27 @@ class RolesController extends APIController
} }
/** /**
* Return the users. * Return the roles.
* *
* @return \Illuminate\Http\Response * @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$limit = $request->get('paginate') ? $request->get('paginate') : 25; $limit = $request->get('paginate') ? $request->get('paginate') : 25;
return RoleResource::collection( return RoleResource::collection(
$this->repository->getPaginated($limit) $this->repository->getForDataTable()->paginate($limit)
); );
} }
/** /**
* Return the specified resource. * Return the specified resource.
* *
* @param User $user * @param Role $role
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function show(Role $role) public function show(Role $role)
{ {
...@@ -49,15 +51,15 @@ class RolesController extends APIController ...@@ -49,15 +51,15 @@ class RolesController extends APIController
} }
/** /**
* Creates the Resourse for Role. * Creates the Resource for Role.
* *
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function store(Request $request) public function store(Request $request)
{ {
$validation = $this->validatingRequest($request); $validation = $this->validateRole($request);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
} }
...@@ -68,14 +70,16 @@ class RolesController extends APIController ...@@ -68,14 +70,16 @@ class RolesController extends APIController
} }
/** /**
* @param Role $role * Update Role.
* @param UpdateRoleRequest $request *
* @param Request $request
* @param Role $role
* *
* @return mixed * @return \Illuminate\Http\JsonResponse
*/ */
public function update(Request $request, Role $role) public function update(Request $request, Role $role)
{ {
$validation = $this->validatingRequest($request); $validation = $this->validateRole($request, $role->id);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
...@@ -88,7 +92,32 @@ class RolesController extends APIController ...@@ -88,7 +92,32 @@ class RolesController extends APIController
return new RoleResource($role); return new RoleResource($role);
} }
public function validatingRequest(Request $request) /**
* Delete Role.
*
* @param Role $role
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function destroy(Role $role, Request $request)
{
$this->repository->delete($role);
return $this->respond([
'message' => trans('alerts.backend.roles.deleted'),
]);
}
/**
* validateUser Role Requests.
*
* @param Request $request
* @param int $id
*
* @return Validator object
*/
public function validateRole(Request $request, $id = 0)
{ {
$permissions = ''; $permissions = '';
...@@ -97,23 +126,10 @@ class RolesController extends APIController ...@@ -97,23 +126,10 @@ class RolesController extends APIController
} }
$validation = Validator::make($request->all(), [ $validation = Validator::make($request->all(), [
'name' => 'required|max:191', 'name' => 'required|max:191|unique:roles,name,'.$id,
'permissions' => $permissions, 'permissions' => $permissions,
]); ]);
return $validation; return $validation;
} }
/**
* @param Role $role
* @param DeleteRoleRequest $request
*
* @return mixed
*/
public function destroy(Role $role, Request $request)
{
$this->repository->delete($role);
return ['message'=>'success'];
}
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api\V1; namespace App\Http\Controllers\Api\V1;
use App\Http\Requests\Backend\Access\User\ManageUserRequest;
use App\Http\Resources\UserResource; use App\Http\Resources\UserResource;
use App\Models\Access\User\User; use App\Models\Access\User\User;
use App\Repositories\Backend\Access\User\UserRepository; use App\Repositories\Backend\Access\User\UserRepository;
...@@ -25,9 +26,11 @@ class UsersController extends APIController ...@@ -25,9 +26,11 @@ class UsersController extends APIController
/** /**
* Return the users. * Return the users.
* *
* @return \Illuminate\Http\Response * @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/ */
public function index(Request $request) public function index(ManageUserRequest $request)
{ {
$limit = $request->get('paginate') ? $request->get('paginate') : 25; $limit = $request->get('paginate') ? $request->get('paginate') : 25;
...@@ -41,56 +44,44 @@ class UsersController extends APIController ...@@ -41,56 +44,44 @@ class UsersController extends APIController
* *
* @param User $user * @param User $user
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function show(User $user) public function show(User $user)
{ {
$data = new UserResource($user); return new UserResource($user);
$history['history'] = history()->renderEntity('User', $user->id);
$maindata = $data->toArray($user);
$maindata = array_merge($maindata, $history);
return $maindata;
} }
/** /**
* Return the specified resource. * Create User.
* *
* @param Request * @param Request $request
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\JsonResponse
*/ */
public function deactivatedUserList(Request $request) public function store(Request $request)
{ {
$limit = $request->get('paginate') ? $request->get('paginate') : 25; $validation = $this->validateUser($request);
return UserResource::collection( if ($validation->fails()) {
$this->repository->getForDataTable(0, false)->paginate($limit) return $this->throwValidation($validation->messages()->first());
); }
}
/** $this->repository->create($request);
* Return the specified resource.
*
* @param User $user
*
* @return \Illuminate\Http\Response
*/
public function deleteUserList(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
return UserResource::collection( return new UserResource(User::orderBy('created_at', 'desc')->first());
$this->repository->getForDataTable(0, true)->paginate($limit)
);
} }
/** /**
* Update the specified resource in storage. * Update User.
*
* @param Request $request
* @param User $user
*
* @return Validator object
*/ */
public function update(Request $request, User $user) public function update(Request $request, User $user)
{ {
$validation = $this->validatingRequest($request, 'edit', $user->id); $validation = $this->validateUser($request, 'edit', $user->id);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
...@@ -104,26 +95,61 @@ class UsersController extends APIController ...@@ -104,26 +95,61 @@ class UsersController extends APIController
} }
/** /**
* Store the specified resource in storage. * Delete User.
*
* @param User $user
* @param Request $request
*
* @return mixed
*/ */
public function store(Request $request) public function destroy(User $user, Request $request)
{ {
$validation = $this->validatingRequest($request); $this->repository->delete($user);
if ($validation->fails()) { return $this->respond([
return $this->throwValidation($validation->messages()->first()); 'message' => trans('alerts.backend.users.deleted'),
]);
}
/**
* Delete All User.
*
* @param Request $request
*
* @return mixed
*/
public function deleteAll(Request $request)
{
$ids = $request->get('ids');
if (isset($ids) && !empty($ids)) {
$result = $this->repository->deleteAll($ids);
} }
$this->repository->create($request);
return new UserResource(User::orderBy('created_at', 'desc')->first()); if ($result) {
return $this->respond([
'message' => trans('alerts.backend.users.deleted'),
]);
}
return $this->respond([
'message' => trans('exceptions.backend.access.users.not_found'),
]);
} }
/** /**
* Validation function to validate user input. * validateUser User.
*
* @param $request
* @param $action
* @param $id
*
* @return \Illuminate\Http\JsonResponse
*/ */
public function validatingRequest(Request $request, $string = '', $id = 0) public function validateUser(Request $request, $action = '', $id = 0)
{ {
$password = ($string == 'edit') ? '' : 'required|min:6|confirmed'; $password = ($action == 'edit') ? '' : 'required|min:6|confirmed';
$validation = Validator::make($request->all(), [ $validation = Validator::make($request->all(), [
'first_name' => 'required|max:255', 'first_name' => 'required|max:255',
'last_name' => 'required|max:255', 'last_name' => 'required|max:255',
...@@ -135,19 +161,4 @@ class UsersController extends APIController ...@@ -135,19 +161,4 @@ class UsersController extends APIController
return $validation; return $validation;
} }
/**
* Api to delete the resource.
*
* @param Role $role
* @param DeleteRoleRequest $request
*
* @return mixed
*/
public function destroy(User $user, Request $request)
{
$this->repository->delete($user);
return ['message' => 'success'];
}
} }
...@@ -23,6 +23,7 @@ class Kernel extends HttpKernel ...@@ -23,6 +23,7 @@ class Kernel extends HttpKernel
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class, \App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\Spatie\Cors\Cors::class,
]; ];
/** /**
......
<?php
namespace App\Http\Requests\Backend\BlogTags;
use App\Http\Requests\Request;
/**
* Class StoreBlogTagsRequest.
*/
class StoreApiBlogTagsRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|max:191',
];
}
/**
* Get the custom validation messages.
*
* @return array
*/
public function messages()
{
return [
'name.required' => 'Blog Tag name is a required field.111111',
'name.max' => 'Blog Tag may not be greater than 191 characters.',
];
}
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Http\Requests; namespace App\Http\Requests;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
/** /**
...@@ -25,4 +26,9 @@ abstract class Request extends FormRequest ...@@ -25,4 +26,9 @@ abstract class Request extends FormRequest
return redirect()->back()->withErrors($this->error); return redirect()->back()->withErrors($this->error);
} }
protected function failedAuthorization()
{
throw new AuthorizationException('This action is unauthorized.');
}
} }
...@@ -16,10 +16,13 @@ class PermissionResource extends Resource ...@@ -16,10 +16,13 @@ class PermissionResource extends Resource
public function toArray($request) public function toArray($request)
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'name' => $this->name, 'name' => $this->name,
'display_name' => $this->display_name, 'display_name' => $this->display_name,
'sort' => $this->sort, 'sort' => $this->sort,
'registered_at' => $this->created_at->toIso8601String(),
'last_updated_at' => $this->updated_at->toIso8601String(),
]; ];
} }
} }
...@@ -16,11 +16,14 @@ class RoleResource extends Resource ...@@ -16,11 +16,14 @@ class RoleResource extends Resource
public function toArray($request) public function toArray($request)
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'name' => $this->name, 'name' => $this->name,
'permission' => ($this->all) ? 'All' : optional($this->permissions)->pluck('display_name'), 'permission' => ($this->all) ? 'All' : optional($this->permissions)->pluck('display_name'),
'noofuses' => $this->users->count(), 'noofuses' => $this->users->count(),
'sort' => $this->sort, 'sort' => $this->sort,
'status' => $this->status,
'registered_at' => $this->created_at->toIso8601String(),
'last_updated_at' => $this->updated_at->toIso8601String(),
]; ];
} }
} }
...@@ -20,11 +20,13 @@ class UserResource extends Resource ...@@ -20,11 +20,13 @@ class UserResource extends Resource
'first_name' => $this->first_name, 'first_name' => $this->first_name,
'last_name' => $this->last_name, 'last_name' => $this->last_name,
'email' => $this->email, 'email' => $this->email,
'picture' => $this->getPicture(),
'confirmed' => $this->confirmed, 'confirmed' => $this->confirmed,
'role' => optional($this->roles()->first())->name, 'role' => optional($this->roles()->first())->name,
'permissions' => $this->permissions()->get(),
'status' => $this->status,
'registered_at' => $this->created_at->toIso8601String(), 'registered_at' => $this->created_at->toIso8601String(),
'last_updated_at' => $this->updated_at->toIso8601String(), 'last_updated_at' => $this->updated_at->toIso8601String(),
]; ];
} }
} }
...@@ -40,7 +40,6 @@ class User extends Authenticatable implements JWTSubject ...@@ -40,7 +40,6 @@ class User extends Authenticatable implements JWTSubject
'first_name', 'first_name',
'last_name', 'last_name',
'email', 'email',
'password',
'status', 'status',
'confirmation_code', 'confirmation_code',
'confirmed', 'confirmed',
...@@ -86,6 +85,15 @@ class User extends Authenticatable implements JWTSubject ...@@ -86,6 +85,15 @@ class User extends Authenticatable implements JWTSubject
*/ */
public function getJWTCustomClaims() public function getJWTCustomClaims()
{ {
return []; return [
'id' => $this->id,
'first_name' => $this->first_name,
'last_name' => $this->last_name,
'email' => $this->email,
'picture' => $this->getPicture(),
'confirmed' => $this->confirmed,
'registered_at' => $this->created_at->toIso8601String(),
'last_updated_at' => $this->updated_at->toIso8601String(),
];
} }
} }
...@@ -31,6 +31,8 @@ class PermissionRepository extends BaseRepository ...@@ -31,6 +31,8 @@ class PermissionRepository extends BaseRepository
config('access.permissions_table').'.name', config('access.permissions_table').'.name',
config('access.permissions_table').'.display_name', config('access.permissions_table').'.display_name',
config('access.permissions_table').'.sort', config('access.permissions_table').'.sort',
config('access.permissions_table').'.created_at',
config('access.permissions_table').'.updated_at',
]); ]);
} }
......
...@@ -49,6 +49,9 @@ class RoleRepository extends BaseRepository ...@@ -49,6 +49,9 @@ class RoleRepository extends BaseRepository
config('access.roles_table').'.name', config('access.roles_table').'.name',
config('access.roles_table').'.all', config('access.roles_table').'.all',
config('access.roles_table').'.sort', config('access.roles_table').'.sort',
config('access.roles_table').'.status',
config('access.roles_table').'.created_at',
config('access.roles_table').'.updated_at',
DB::raw("GROUP_CONCAT( DISTINCT permissions.display_name SEPARATOR '<br/>') as permission_name"), DB::raw("GROUP_CONCAT( DISTINCT permissions.display_name SEPARATOR '<br/>') as permission_name"),
DB::raw('(SELECT COUNT(role_user.id) FROM role_user LEFT JOIN users ON role_user.user_id = users.id WHERE role_user.role_id = roles.id AND users.deleted_at IS NULL) AS userCount'), DB::raw('(SELECT COUNT(role_user.id) FROM role_user LEFT JOIN users ON role_user.user_id = users.id WHERE role_user.role_id = roles.id AND users.deleted_at IS NULL) AS userCount'),
]) ])
......
...@@ -142,8 +142,9 @@ class UserRepository extends BaseRepository ...@@ -142,8 +142,9 @@ class UserRepository extends BaseRepository
DB::transaction(function () use ($user, $data, $roles, $permissions) { DB::transaction(function () use ($user, $data, $roles, $permissions) {
if ($user->update($data)) { if ($user->update($data)) {
$user->status = isset($data['status']) ? 1 : 0; $user->status = isset($data['status']) && $data['status'] == '1' ? 1 : 0;
$user->confirmed = isset($data['confirmed']) ? 1 : 0; $user->confirmed = isset($data['confirmed']) && $data['confirmed'] == '1' ? 1 : 0;
$user->save(); $user->save();
$this->checkUserRolesCount($roles); $this->checkUserRolesCount($roles);
...@@ -189,6 +190,8 @@ class UserRepository extends BaseRepository ...@@ -189,6 +190,8 @@ class UserRepository extends BaseRepository
} }
/** /**
* Delete User.
*
* @param Model $user * @param Model $user
* *
* @throws GeneralException * @throws GeneralException
...@@ -210,6 +213,34 @@ class UserRepository extends BaseRepository ...@@ -210,6 +213,34 @@ class UserRepository extends BaseRepository
throw new GeneralException(trans('exceptions.backend.access.users.delete_error')); throw new GeneralException(trans('exceptions.backend.access.users.delete_error'));
} }
/**
* Delete All Users.
*
* @param Model $user
*
* @throws GeneralException
*
* @return bool
*/
public function deleteAll($ids)
{
if (in_array(access()->id(), $ids)) {
throw new GeneralException(trans('exceptions.backend.access.users.cant_delete_self'));
}
if (in_array(1, $ids)) {
throw new GeneralException(trans('exceptions.backend.access.users.cant_delete_admin'));
}
$result = DB::table('users')->whereIn('id', $ids)->delete();
if ($result) {
return true;
}
return false;
}
/** /**
* @param $user * @param $user
* *
......
This diff is collapsed.
...@@ -70,6 +70,11 @@ return [ ...@@ -70,6 +70,11 @@ return [
*/ */
'history_types_table' => 'history_types', 'history_types_table' => 'history_types',
/*
* History table used to store History
*/
'history_table' => 'history',
/* /*
* Notifications table used to store user notification * Notifications table used to store user notification
*/ */
...@@ -99,7 +104,7 @@ return [ ...@@ -99,7 +104,7 @@ return [
/* /*
* Whether or not the user has to confirm their email when signing up * Whether or not the user has to confirm their email when signing up
*/ */
'confirm_email' => true, 'confirm_email' => false,
/* /*
* Whether or not the users email can be changed on the edit profile screen * Whether or not the users email can be changed on the edit profile screen
......
<?php
return [
/*
* A cors profile determines which origins, methods, headers are allowed for
* a given requests. The `DefaultProfile` reads its configuration from this
* config file.
*
* You can easily create your own cors profile.
* More info: https://github.com/spatie/laravel-cors/#creating-your-own-cors-profile
*/
'cors_profile' => Spatie\Cors\CorsProfile\DefaultProfile::class,
/*
* This configuration is used by `DefaultProfile`.
*/
'default_profile' => [
'allow_origins' => [
'*',
],
'allow_methods' => [
'POST',
'GET',
'OPTIONS',
'PUT',
'PATCH',
'DELETE',
],
'allow_headers' => [
'Content-Type',
'X-Auth-Token',
'Origin',
'x-xsrf-token',
'x_csrftoken',
'Authorization',
],
'forbidden_response' => [
'message' => 'Forbidden (cors).',
'status' => 403,
],
/*
* Preflight request will respond with value for the max age header.
*/
'max_age' => 60 * 60 * 24,
],
];
...@@ -22,6 +22,7 @@ class HistoryTypeTableSeeder extends Seeder ...@@ -22,6 +22,7 @@ class HistoryTypeTableSeeder extends Seeder
{ {
$this->disableForeignKeys(); $this->disableForeignKeys();
$this->truncate(config('access.history_types_table')); $this->truncate(config('access.history_types_table'));
$this->truncate(config('access.history_table'));
$types = [ $types = [
[ [
......
...@@ -117,11 +117,9 @@ var Backend = {}; // common variable used in all the files of the backend ...@@ -117,11 +117,9 @@ var Backend = {}; // common variable used in all the files of the backend
associated_container: document.getElementById("#available-permissions"), associated_container: document.getElementById("#available-permissions"),
}, },
init(page) { init(page) {
this.setSelectors(); this.setSelectors();
this.setRolepermission(page); this.setRolepermission(page);
this.addHandlers(); this.addHandlers();
}, },
setSelectors: function () { setSelectors: function () {
this.selectors.associated = document.querySelector("select[name='associated_permissions']"); this.selectors.associated = document.querySelector("select[name='associated_permissions']");
...@@ -697,17 +695,17 @@ var Backend = {}; // common variable used in all the files of the backend ...@@ -697,17 +695,17 @@ var Backend = {}; // common variable used in all the files of the backend
*/ */
Faq: Faq:
{ {
selectors: selectors:
{ {
}, },
init: function () { init: function () {
// this.addHandlers(); // this.addHandlers();
Backend.tinyMCE.init(); Backend.tinyMCE.init();
}, },
addHandlers: function () { addHandlers: function () {
} }
}, },
/** /**
...@@ -735,7 +733,6 @@ var Backend = {}; // common variable used in all the files of the backend ...@@ -735,7 +733,6 @@ var Backend = {}; // common variable used in all the files of the backend
if (this.selectors.cities != null) { if (this.selectors.cities != null) {
this.selectors.cities.select2(); this.selectors.cities.select2();
} }
} }
}, },
...@@ -842,6 +839,10 @@ var Backend = {}; // common variable used in all the files of the backend ...@@ -842,6 +839,10 @@ var Backend = {}; // common variable used in all the files of the backend
}, },
/**
* Settings
*
*/
Settings: Settings:
{ {
selectors: { selectors: {
...@@ -898,9 +899,7 @@ var Backend = {}; // common variable used in all the files of the backend ...@@ -898,9 +899,7 @@ var Backend = {}; // common variable used in all the files of the backend
Backend.Utils.ajaxrequest(route, "POST", { data: value, _token: Backend.Utils.csrf }, Backend.Utils.csrf, callback); Backend.Utils.ajaxrequest(route, "POST", { data: value, _token: Backend.Utils.csrf }, Backend.Utils.csrf, callback);
} }
}); });
}; };
} }
} }
}; };
......
...@@ -37,6 +37,7 @@ return [ ...@@ -37,6 +37,7 @@ return [
'users' => [ 'users' => [
'cant_deactivate_self' => 'You can not do that to yourself.', 'cant_deactivate_self' => 'You can not do that to yourself.',
'cant_delete_self' => 'You can not delete yourself.', 'cant_delete_self' => 'You can not delete yourself.',
'cant_delete_admin' => 'You can not delete Admin.',
'cant_delete_own_session' => 'You can not delete your own session.', 'cant_delete_own_session' => 'You can not delete your own session.',
'cant_delete_own_session' => 'You can not delete your own session.', 'cant_delete_own_session' => 'You can not delete your own session.',
'cant_restore' => 'This user is not deleted so it can not be restored.', 'cant_restore' => 'This user is not deleted so it can not be restored.',
......
<?php <?php
/* /*
...@@ -27,32 +27,33 @@ Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], functio ...@@ -27,32 +27,33 @@ Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], functio
Route::post('password/email', 'ForgotPasswordController@sendResetLinkEmail'); Route::post('password/email', 'ForgotPasswordController@sendResetLinkEmail');
// Route::post('password/reset', 'ResetPasswordController@reset')->name('password.reset'); // Route::post('password/reset', 'ResetPasswordController@reset')->name('password.reset');
}); });
// Users // Users
Route::group(['prefix' => 'users'], function () { Route::resource('users', 'UsersController', ['except' => ['create', 'edit']]);
Route::get('deactiveUsers', 'UsersController@deactivatedUserList'); Route::post('users/delete-all', 'UsersController@deleteAll');
Route::get('deleteUsers', 'UsersController@deleteUserList'); //@todo need to change the route name and related changes
}); Route::get('deactivated-users', 'DeactivatedUsersController@index');
Route::resource('users', 'UsersController'); Route::get('deleted-users', 'DeletedUsersController@index');
// Roles // Roles
Route::resource('roles', 'RolesController'); Route::resource('roles', 'RolesController', ['except' => ['create', 'edit']]);
Route::post('roles/delete-all', 'RolesController@deleteAll');
// Permission // Permission
Route::resource('permission', 'PermissionController'); Route::resource('permissions', 'PermissionController', ['except' => ['create', 'edit']]);
// Page // Page
Route::resource('pages', 'PagesController'); Route::resource('pages', 'PagesController', ['except' => ['create', 'edit']]);
// Faqs // Faqs
Route::resource('faqs', 'FaqsController'); Route::resource('faqs', 'FaqsController', ['except' => ['create', 'edit']]);
// Blog Categories // Blog Categories
Route::resource('blog_categories', 'BlogCategoriesController'); Route::resource('blog_categories', 'BlogCategoriesController', ['except' => ['create', 'edit']]);
// Blog Tags // Blog Tags
Route::resource('blog_tags', 'BlogTagsController'); Route::resource('blog_tags', 'BlogTagsController', ['except' => ['create', 'edit']]);
// Blogs // Blogs
Route::resource('blogs', 'BlogsController'); Route::resource('blogs', 'BlogsController', ['except' => ['create', 'edit']]);
}); });
}); });
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