Unverified Commit 80481dd7 authored by Ruchit Patel's avatar Ruchit Patel Committed by GitHub

Merge pull request #2 from viralsolani/master

Pull request
parents 179c24b1 81c9b0d7
# laravel-adminpanel # laravel-adminpanel
[![License](https://img.shields.io/badge/License-MIT-red.svg)](https://github.com/viralsolani/laravel-adminpanel/blob/master/LICENSE.txt) [![GitHub license](https://img.shields.io/github/license/viralsolani/laravel-adminpanel.svg?style=plastic)](https://github.com/viralsolani/laravel-adminpanel/blob/master/LICENSE.txt)
[![StyleCI](https://styleci.io/repos/30171828/shield?style=plastic)](https://styleci.io/repos/105789824/shield?style=plastic) [![GitHub stars](https://img.shields.io/github/stars/viralsolani/laravel-adminpanel.svg?style=plastic)](https://github.com/viralsolani/laravel-adminpanel/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/viralsolani/laravel-adminpanel.svg?style=plastic)](https://github.com/viralsolani/laravel-adminpanel/network)
[![GitHub issues](https://img.shields.io/github/issues/viralsolani/laravel-adminpanel.svg?style=plastic)](https://github.com/viralsolani/laravel-adminpanel/issues)
![StyleCI](https://img.shields.io/badge/styleCI-passed-brightgreen.svg?style=plastic)
## Introduction ## Introduction
...@@ -17,7 +20,7 @@ For Laravel 5 Boilerplate Features : [Features](https://github.com/rappasoft/lar ...@@ -17,7 +20,7 @@ For Laravel 5 Boilerplate Features : [Features](https://github.com/rappasoft/lar
* Email Template Module * Email Template Module
* Blog Module * Blog Module
* FAQ Module * FAQ Module
* API Boilerplate - Coming Soon. * API Boilerplate.
Give your project a Head Start by using [laravel-adminpanel](https://github.com/viralsolani/laravel-adminpanel). Give your project a Head Start by using [laravel-adminpanel](https://github.com/viralsolani/laravel-adminpanel).
...@@ -64,7 +67,7 @@ Install the javascript dependencies using npm ...@@ -64,7 +67,7 @@ Install the javascript dependencies using npm
Compile the dependencies Compile the dependencies
npm run development npm run development
Start the local development server Start the local development server
...@@ -83,6 +86,27 @@ You can now access the server at http://localhost:8000 ...@@ -83,6 +86,27 @@ You can now access the server at http://localhost:8000
php artisan key:generate php artisan key:generate
php artisan jwt:generate php artisan jwt:generate
## Logging In
`php artisan db:seed` adds three users with respective roles. The credentials are as follows:
* Admin Istrator: `admin@admin.com`
* Backend User: `executive@executive.com`
* Default User: `user@user.com`
Password: `1234`
## ScreenShots
## Dashboard
![Screenshot](screenshots/dashboard.png)
## User Listing
![Screenshot](screenshots/users.png)
## Settings
![Screenshot](screenshots/settings.png)
## Issues ## Issues
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).
...@@ -92,4 +116,4 @@ Feel free to create any pull requests for the project. For propsing any new chan ...@@ -92,4 +116,4 @@ Feel free to create any pull requests for the project. For propsing any new chan
## License ## License
[MIT LICENSE](https://github.com/viralsolani/laravel-adminpanel/blob/master/LICENSE.txt) [MIT LICENSE](https://github.com/viralsolani/laravel-adminpanel/blob/master/LICENSE.txt)
\ No newline at end of file
...@@ -8,7 +8,7 @@ require __DIR__.'/Search.php'; ...@@ -8,7 +8,7 @@ require __DIR__.'/Search.php';
require __DIR__.'/Access/User.php'; require __DIR__.'/Access/User.php';
require __DIR__.'/Access/Role.php'; require __DIR__.'/Access/Role.php';
require __DIR__.'/Access/Permission.php'; require __DIR__.'/Access/Permission.php';
require __DIR__.'/CMS_Page.php'; require __DIR__.'/Page.php';
require __DIR__.'/Email_Template.php'; require __DIR__.'/Email_Template.php';
require __DIR__.'/Setting.php'; require __DIR__.'/Setting.php';
require __DIR__.'/Blog_Category.php'; require __DIR__.'/Blog_Category.php';
......
<?php
Breadcrumbs::register('admin.cmspages.index', function ($breadcrumbs) {
$breadcrumbs->parent('admin.dashboard');
$breadcrumbs->push(trans('menus.backend.cmspages.management'), route('admin.cmspages.index'));
});
Breadcrumbs::register('admin.cmspages.create', function ($breadcrumbs) {
$breadcrumbs->parent('admin.cmspages.index');
$breadcrumbs->push(trans('menus.backend.cmspages.create'), route('admin.cmspages.create'));
});
Breadcrumbs::register('admin.cmspages.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.cmspages.index');
$breadcrumbs->push(trans('menus.backend.cmspages.edit'), route('admin.cmspages.edit', $id));
});
<?php
Breadcrumbs::register('admin.pages.index', function ($breadcrumbs) {
$breadcrumbs->parent('admin.dashboard');
$breadcrumbs->push(trans('menus.backend.pages.management'), route('admin.pages.index'));
});
Breadcrumbs::register('admin.pages.create', function ($breadcrumbs) {
$breadcrumbs->parent('admin.pages.index');
$breadcrumbs->push(trans('menus.backend.pages.create'), route('admin.pages.create'));
});
Breadcrumbs::register('admin.pages.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.pages.index');
$breadcrumbs->push(trans('menus.backend.pages.edit'), route('admin.pages.edit', $id));
});
...@@ -33,7 +33,7 @@ class APIController extends Controller ...@@ -33,7 +33,7 @@ class APIController extends Controller
* *
* @param [type] $statusCode [description] * @param [type] $statusCode [description]
* *
* @return mix * @return statuscode
*/ */
public function setStatusCode($statusCode) public function setStatusCode($statusCode)
{ {
...@@ -42,37 +42,13 @@ class APIController extends Controller ...@@ -42,37 +42,13 @@ class APIController extends Controller
return $this; return $this;
} }
/**
* responsd not found.
*
* @param string $message
*
* @return mix
*/
public function respondNotFound($message = 'Not Found')
{
return $this->setStatusCode(IlluminateResponse::HTTP_NOT_FOUND)->respondWithError($message);
}
/**
* Respond with error.
*
* @param string $message
*
* @return mix
*/
public function respondInternalError($message = 'Internal Error')
{
return $this->setStatusCode('500')->respondWithError($message);
}
/** /**
* Respond. * Respond.
* *
* @param array $data * @param array $data
* @param array $headers * @param array $headers
* *
* @return mix * @return \Illuminate\Http\JsonResponse
*/ */
public function respond($data, $headers = []) public function respond($data, $headers = [])
{ {
...@@ -85,7 +61,7 @@ class APIController extends Controller ...@@ -85,7 +61,7 @@ class APIController extends Controller
* @param Paginator $items * @param Paginator $items
* @param array $data * @param array $data
* *
* @return mix * @return \Illuminate\Http\JsonResponse
*/ */
public function respondWithPagination($items, $data) public function respondWithPagination($items, $data)
{ {
...@@ -101,12 +77,38 @@ class APIController extends Controller ...@@ -101,12 +77,38 @@ class APIController extends Controller
return $this->respond($data); return $this->respond($data);
} }
/**
* Respond Created.
*
* @param string $message
*
* @return \Illuminate\Http\JsonResponse
*/
public function respondCreated($data)
{
return $this->setStatusCode(201)->respond([
'data' => $data,
]);
}
/**
* Respond Created with data.
*
* @param string $message
*
* @return \Illuminate\Http\JsonResponse
*/
public function respondCreatedWithData($data)
{
return $this->setStatusCode(201)->respond($data);
}
/** /**
* respond with error. * respond with error.
* *
* @param $message * @param $message
* *
* @return mix * @return \Illuminate\Http\JsonResponse
*/ */
public function respondWithError($message) public function respondWithError($message)
{ {
...@@ -119,17 +121,61 @@ class APIController extends Controller ...@@ -119,17 +121,61 @@ class APIController extends Controller
} }
/** /**
* Respond Created. * responsd not found.
* *
* @param string $message * @param string $message
* *
* @return mix * @return \Illuminate\Http\JsonResponse
*/ */
public function respondCreated($message) public function respondNotFound($message = 'Not Found')
{ {
return $this->setStatusCode(201)->respond([ return $this->setStatusCode(IlluminateResponse::HTTP_NOT_FOUND)->respondWithError($message);
'message' => $message, }
]);
/**
* Respond with error.
*
* @param string $message
*
* @return \Illuminate\Http\JsonResponse
*/
public function respondInternalError($message = 'Internal Error')
{
return $this->setStatusCode(500)->respondWithError($message);
}
/**
* Respond with unauthorized.
*
* @param string $message
*
* @return \Illuminate\Http\JsonResponse
*/
protected function respondUnauthorized($message = 'Unauthorized')
{
return $this->setStatusCode(401)->respondWithError($message);
}
/**
* Respond with forbidden.
*
* @param string $message
*
* @return \Illuminate\Http\JsonResponse
*/
protected function respondForbidden($message = 'Forbidden')
{
return $this->setStatusCode(403)->respondWithError($message);
}
/**
* Respond with no content.
*
* @return \Illuminate\Http\JsonResponse
*/
protected function respondWithNoContent()
{
return $this->setStatusCode(204)->respond(null);
} }
/** /**
......
...@@ -2,77 +2,52 @@ ...@@ -2,77 +2,52 @@
namespace App\Http\Controllers\Api\V1; namespace App\Http\Controllers\Api\V1;
use App\Models\Access\User\User;
use App\Notifications\Activated;
use App\Notifications\Activation;
use App\Notifications\PasswordReset;
use App\Notifications\PasswordResetted;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use JWTAuth; use JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException; use Tymon\JWTAuth\Exceptions\JWTException;
use Validator; use Validator;
/**
* AuthController.
*/
class AuthController extends APIController class AuthController extends APIController
{ {
/** /**
* Authenticate User. * Log the user in.
* *
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function authenticate(Request $request) public function login(Request $request)
{ {
$credentials = $request->only('email', 'password'); $validation = Validator::make($request->all(), [
'email' => 'required|email',
'password' => 'required|min:4',
]);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$credentials = $request->only(['email', 'password']);
try { try {
if (!$token = JWTAuth::attempt($credentials)) { if (!$token = JWTAuth::attempt($credentials)) {
return $this->throwValidation('Invalid Credentials! Please try again.'); return $this->throwValidation(trans('api.messages.login.failed'));
} }
} catch (JWTException $e) { } catch (JWTException $e) {
return $this->respondInternalError('This is something wrong. Please try again!'); return $this->respondInternalError($e->getMessage());
}
$user = User::whereEmail(request('email'))->first();
if ($user->status != 1) {
return $this->throwValidation('Your account hasn\'t been activated. Please check your email & activate account.');
} }
return $this->respond([ return $this->respond([
'message' => 'You are successfully logged in!', 'message' => trans('api.messages.login.success'),
'token' => $token, 'token' => $token,
]); ]);
} }
/** /**
* Check if user is authenticated or not. * Log the user out (Invalidate the token).
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function check()
{
try {
JWTAuth::parseToken()->authenticate();
} catch (JWTException $e) {
return $this->respond([
'authenticated' => false,
]);
}
return $this->respond([
'authenticated' => true,
]);
}
/**
* Log Out.
*
* @return \Illuminate\Http\JsonResponse
*/
public function logout() public function logout()
{ {
try { try {
...@@ -82,190 +57,36 @@ class AuthController extends APIController ...@@ -82,190 +57,36 @@ class AuthController extends APIController
JWTAuth::invalidate($token); JWTAuth::invalidate($token);
} }
} catch (JWTException $e) { } catch (JWTException $e) {
return $this->respondInternalError('This is something wrong. Please try again!'); return $this->respondInternalError($e->getMessage());
} }
return $this->respond([ return $this->respond([
'message' => 'You are successfully logged out!', 'message' => trans('api.messages.logout.success'),
]);
}
/**
* Register User.
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function register(Request $request)
{
$validation = Validator::make($request->all(), [
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required|email|unique:users',
'password' => 'required|min:6',
'password_confirmation' => 'required|same:password',
]);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$user = User::create([
'first_name' => request('first_name'),
'last_name' => request('last_name'),
'email' => request('email'),
'status' => '0',
'password' => bcrypt(request('password')),
'country_id' => 1,
'state_id' => 1,
'city_id' => 1,
'zip_code' => 1,
'ssn' => 123456789,
'created_by' => 1,
]);
$user->confirmation_code = generateUuid();
$user->save();
$user->notify(new Activation($user));
return $this->respondCreated([
'You have registered successfully. Please check your email for activation!',
]); ]);
} }
/** /**
* Activate User. * Refresh a token.
*
* @param $activation_token [description]
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function activate($activation_token) public function refresh()
{ {
$user = User::whereConfirmationCode($activation_token)->first(); $token = JWTAuth::getToken();
if (!$user) { if (!$token) {
return $this->throwValidation('Invalid activation token!'); $this->respondUnauthorized(trans('api.messages.refresh.token.not_provided'));
} }
if ($user->status == 1) { try {
return $this->throwValidation('Your account has already been activated!'); $refreshedToken = JWTAuth::refresh($token);
} catch (JWTException $e) {
return $this->respondInternalError($e->getMessage());
} }
$user->confirmed = 1;
$user->status = 1;
$user->save();
$user->notify(new Activated($user));
return $this->respond([ return $this->respond([
'message' => 'Your account has been activated!', 'status' => trans('api.messages.refresh.status'),
]); 'token' => $refreshedToken,
}
public function password(Request $request)
{
$validation = Validator::make($request->all(), [
'email' => 'required|email',
]); ]);
if ($validation->fails()) {
return response()->json(['message' => $validation->messages()->first()], 422);
}
$user = User::whereEmail(request('email'))->first();
if (!$user) {
return response()->json(['message' => 'We couldn\'t found any user with this email. Please try again!'], 422);
}
$token = generateUuid();
\DB::table('password_resets')->insert([
'email' => request('email'),
'token' => $token,
]);
$user->notify(new PasswordReset($user, $token));
return response()->json(['message' => 'We have sent reminder email. Please check your inbox!']);
}
public function validatePasswordReset(Request $request)
{
$validate_password_request = \DB::table('password_resets')->where('token', '=', request('token'))->first();
if (!$validate_password_request) {
return response()->json(['message' => 'Invalid password reset token!'], 422);
}
if (date('Y-m-d H:i:s', strtotime($validate_password_request->created_at.'+30 minutes')) < date('Y-m-d H:i:s')) {
return response()->json(['message' => 'Password reset token is expired. Please request reset password again!'], 422);
}
return response()->json(['message' => '']);
}
public function reset(Request $request)
{
$validation = Validator::make($request->all(), [
'email' => 'required|email',
'password' => 'required|min:6',
'password_confirmation' => 'required|same:password',
]);
if ($validation->fails()) {
return response()->json(['message' => $validation->messages()->first()], 422);
}
$user = User::whereEmail(request('email'))->first();
if (!$user) {
return response()->json(['message' => 'We couldn\'t found any user with this email. Please try again!'], 422);
}
$validate_password_request = \DB::table('password_resets')->where('email', '=', request('email'))->where('token', '=', request('token'))->first();
if (!$validate_password_request) {
return response()->json(['message' => 'Invalid password reset token!'], 422);
}
if (date('Y-m-d H:i:s', strtotime($validate_password_request->created_at.'+30 minutes')) < date('Y-m-d H:i:s')) {
return response()->json(['message' => 'Password reset token is expired. Please request reset password again!'], 422);
}
$user->password = bcrypt(request('password'));
$user->save();
$user->notify(new PasswordResetted($user));
return response()->json(['message' => 'Your password has been reset. Please login again!']);
}
public function changePassword(Request $request)
{
if (env('IS_DEMO')) {
return response()->json(['message' => 'You are not allowed to perform this action in this mode.'], 422);
}
$validation = Validator::make($request->all(), [
'current_password' => 'required',
'new_password' => 'required|confirmed|different:current_password|min:6',
'new_password_confirmation' => 'required|same:new_password',
]);
if ($validation->fails()) {
return response()->json(['message' => $validation->messages()->first()], 422);
}
$user = JWTAuth::parseToken()->authenticate();
if (!\Hash::check(request('current_password'), $user->password)) {
return response()->json(['message' => 'Old password does not match! Please try again!'], 422);
}
$user->password = bcrypt(request('new_password'));
$user->save();
return response()->json(['message' => 'Your password has been changed successfully!']);
} }
} }
<?php
namespace App\Http\Controllers\Api\V1;
use App\Models\User\User;
use App\Notifications\Frontend\Auth\UserNeedsPasswordReset;
use App\Repositories\Frontend\Access\User\UserRepository;
use Illuminate\Http\Request;
use Validator;
class ForgotPasswordController extends APIController
{
/**
* __construct.
*
* @param $repository
*/
public function __construct(UserRepository $repository)
{
$this->repository = $repository;
}
/**
* Send a reset link to the given user.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function sendResetLinkEmail(Request $request)
{
$validation = Validator::make($request->all(), [
'email' => 'required|email',
]);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$user = $this->repository->findByEmail($request->get('email'));
if (!$user) {
return $this->respondNotFound(trans('api.messages.forgot_password.validation.email_not_found'));
}
$token = $this->repository->saveToken();
$user->notify(new UserNeedsPasswordReset($token));
return $this->respond([
'status' => 'ok',
'message' => trans('api.messages.forgot_password.success'),
]);
}
}
<?php
namespace App\Http\Controllers\Api\V1;
use App\Models\User\User;
use App\Repositories\Frontend\Access\User\UserRepository;
use Config;
use Illuminate\Http\Request;
use JWTAuth;
use Validator;
class RegisterController extends APIController
{
protected $repository;
/**
* __construct.
*
* @param $repository
*/
public function __construct(UserRepository $repository)
{
$this->repository = $repository;
}
/**
* Register User.
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function register(Request $request)
{
$validation = Validator::make($request->all(), [
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required|email|unique:users',
'password' => 'required|min:4',
'password_confirmation' => 'required|same:password',
'is_term_accept' => 'required',
]);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$user = $this->repository->create($request->all());
if (!Config::get('api.register.release_token')) {
return $this->respondCreated([
'message' => trans('api.messages.registeration.success'),
]);
}
$token = JWTAuth::fromUser($user);
return $this->respondCreated([
'message' => trans('api.messages.registeration.success'),
'token' => $token,
]);
}
}
<?php
namespace App\Http\Controllers\Api\V1;
use App\Http\Resources\UserResource;
use App\Models\User\User;
use App\Repositories\Backend\Access\User\UserRepository;
use Illuminate\Http\Request;
use Validator;
class UsersController extends APIController
{
protected $repository;
/**
* __construct.
*
* @param $repository
*/
public function __construct(UserRepository $repository)
{
$this->repository = $repository;
}
/**
* Return the users.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
return UserResource::collection(
$this->repository->getPaginated($limit)
);
}
/**
* Return the specified resource.
*
* @param User $user
*
* @return \Illuminate\Http\Response
*/
public function show(User $user)
{
return new UserResource($user);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, User $user)
{
$validation = Validator::make($request->all(), [
'name' => 'required',
'email' => 'email|unique:users,email,'.$user->id,
'password' => 'nullable|confirmed',
]);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$user = $this->repository->update($user->id, $request->all());
return new UserResource($user);
}
}
...@@ -23,9 +23,9 @@ class EmailTemplatesController extends Controller ...@@ -23,9 +23,9 @@ class EmailTemplatesController extends Controller
protected $emailtemplates; protected $emailtemplates;
/** /**
* Setting the EmailTemplatesRepository instance to class variable. * __construct.
* *
* @param EmailTemplatesRepository $emailtemplates * @param \App\Repositories\Backend\EmailTemplates\EmailTemplatesRepository $emailtemplates
*/ */
public function __construct(EmailTemplatesRepository $emailtemplates) public function __construct(EmailTemplatesRepository $emailtemplates)
{ {
...@@ -33,9 +33,7 @@ class EmailTemplatesController extends Controller ...@@ -33,9 +33,7 @@ class EmailTemplatesController extends Controller
} }
/** /**
* Use to load index view of EmailTmplates. * @param \App\Http\Requests\Backend\EmailTemplates\ManageEmailTemplatesRequest $request
*
* @param ManageEmailTemplatesRequest $request
* *
* @return mixed * @return mixed
*/ */
...@@ -45,18 +43,16 @@ class EmailTemplatesController extends Controller ...@@ -45,18 +43,16 @@ class EmailTemplatesController extends Controller
} }
/** /**
* Use to load edit form of Emailtemplate. * @param \App\Models\EmailTemplates\EmailTemplate $emailtemplate
* * @param \App\Http\Requests\Backend\EmailTemplates\EditEmailTemplatesRequest $request
* @param EmailTemplate $emailtemplate
* @param EditEmailTemplatesRequest $request
* *
* @return mixed * @return mixed
*/ */
public function edit(EmailTemplate $emailtemplate, EditEmailTemplatesRequest public function edit(EmailTemplate $emailtemplate, EditEmailTemplatesRequest
$request) $request)
{ {
$emailtemplateTypes = EmailTemplateType::pluck('name', 'id'); $emailtemplateTypes = EmailTemplateType::getSelectData();
$emailtemplatePlaceholders = EmailTemplatePlaceholder::pluck('name', 'id'); $emailtemplatePlaceholders = EmailTemplatePlaceholder::getSelectData();
return view('backend.emailtemplates.edit') return view('backend.emailtemplates.edit')
->withEmailtemplate($emailtemplate) ->withEmailtemplate($emailtemplate)
...@@ -65,27 +61,23 @@ class EmailTemplatesController extends Controller ...@@ -65,27 +61,23 @@ class EmailTemplatesController extends Controller
} }
/** /**
* Use to update an Emailtemplate. * @param \App\Models\EmailTemplates\EmailTemplate $emailtemplate
* * @param \App\Http\Requests\Backend\EmailTemplates\UpdateEmailTemplatesRequest $request
* @param EmailTemplate $emailtemplate
* @param UpdateEmailTemplatesRequest $request
* *
* @return mixed * @return mixed
*/ */
public function update(EmailTemplate $emailtemplate, UpdateEmailTemplatesRequest public function update(EmailTemplate $emailtemplate, UpdateEmailTemplatesRequest
$request) $request)
{ {
$this->emailtemplates->update($emailtemplate, $request->all()); $this->emailtemplates->update($emailtemplate, $request->except(['_method', '_token', 'placeholder']));
return redirect()->route('admin.emailtemplates.index') return redirect()->route('admin.emailtemplates.index')
->withFlashSuccess(trans('alerts.backend.emailtemplates.updated')); ->withFlashSuccess(trans('alerts.backend.emailtemplates.updated'));
} }
/** /**
* Use to delete an Emailtemplate. * @param \App\Models\EmailTemplates\EmailTemplate $emailtemplate
* * @param \App\Http\Requests\Backend\EmailTemplates\DeleteEmailTemplatesRequest $request
* @param EmailTemplate $emailtemplate
* @param DeleteEmailTemplatesRequest $request
* *
* @return mixed * @return mixed
*/ */
......
...@@ -19,7 +19,7 @@ class EmailTemplatesTableController extends Controller ...@@ -19,7 +19,7 @@ class EmailTemplatesTableController extends Controller
protected $emailtemplates; protected $emailtemplates;
/** /**
* @param EmailTemplatesRepository $emailtemplates * @param \App\Repositories\Backend\EmailTemplates\EmailTemplatesRepository $emailtemplates
*/ */
public function __construct(EmailTemplatesRepository $emailtemplates) public function __construct(EmailTemplatesRepository $emailtemplates)
{ {
...@@ -27,7 +27,7 @@ class EmailTemplatesTableController extends Controller ...@@ -27,7 +27,7 @@ class EmailTemplatesTableController extends Controller
} }
/** /**
* @param ManageEmailTemplatesRequest $request * @param \App\Http\Requests\Backend\EmailTemplates\ManageEmailTemplatesRequest $request
* *
* @return mixed * @return mixed
*/ */
...@@ -36,11 +36,7 @@ class EmailTemplatesTableController extends Controller ...@@ -36,11 +36,7 @@ class EmailTemplatesTableController extends Controller
return Datatables::of($this->emailtemplates->getForDataTable()) return Datatables::of($this->emailtemplates->getForDataTable())
->escapeColumns(['title']) ->escapeColumns(['title'])
->addColumn('status', function ($emailtemplates) { ->addColumn('status', function ($emailtemplates) {
if ($emailtemplates->status) { return $emailtemplates->status_label;
return '<span class="label label-success">Active</span>';
}
return '<span class="label label-danger">Inactive</span>';
}) })
->addColumn('created_at', function ($emailtemplates) { ->addColumn('created_at', function ($emailtemplates) {
return Carbon::parse($emailtemplates->created_at)->toDateString(); return Carbon::parse($emailtemplates->created_at)->toDateString();
......
...@@ -23,7 +23,7 @@ class PagesController extends Controller ...@@ -23,7 +23,7 @@ class PagesController extends Controller
protected $pages; protected $pages;
/** /**
* @param PagesRepository $pages * @param \App\Repositories\Backend\Pages\PagesRepository $pages
*/ */
public function __construct(PagesRepository $pages) public function __construct(PagesRepository $pages)
{ {
...@@ -31,7 +31,7 @@ class PagesController extends Controller ...@@ -31,7 +31,7 @@ class PagesController extends Controller
} }
/** /**
* @param ManagePageRequest $request * @param \App\Http\Requests\Backend\Pages\ManagePageRequest $request
* *
* @return mixed * @return mixed
*/ */
...@@ -41,7 +41,7 @@ class PagesController extends Controller ...@@ -41,7 +41,7 @@ class PagesController extends Controller
} }
/** /**
* @param CreatePageRequest $request * @param \App\Http\Requests\Backend\Pages\CreatePageRequest $request
* *
* @return mixed * @return mixed
*/ */
...@@ -51,45 +51,45 @@ class PagesController extends Controller ...@@ -51,45 +51,45 @@ class PagesController extends Controller
} }
/** /**
* @param StorePageRequest $request * @param \App\Http\Requests\Backend\Pages\StorePageRequest $request
* *
* @return mixed * @return mixed
*/ */
public function store(StorePageRequest $request) public function store(StorePageRequest $request)
{ {
$this->pages->create($request->all()); $this->pages->create($request->except(['_token']));
return redirect()->route('admin.pages.index')->withFlashSuccess(trans('alerts.backend.pages.created')); return redirect()->route('admin.pages.index')->withFlashSuccess(trans('alerts.backend.pages.created'));
} }
/** /**
* @param Page $page * @param \App\Models\Page\Page $page
* @param EditPageRequest $request * @param \App\Http\Requests\Backend\Pages\EditPageRequest $request
* *
* @return mixed * @return mixed
*/ */
public function edit(Page $page, EditPageRequest $request) public function edit(Page $page, EditPageRequest $request)
{ {
return view('backend.pages.edit') return view('backend.pages.edit')
->withCmspage($page); ->withPage($page);
} }
/** /**
* @param Page $page * @param \App\Models\Page\Page $page
* @param UpdatePageRequest $request * @param \App\Http\Requests\Backend\Pages\UpdatePageRequest $request
* *
* @return mixed * @return mixed
*/ */
public function update(Page $page, UpdatePageRequest $request) public function update(Page $page, UpdatePageRequest $request)
{ {
$this->pages->update($page, $request->all()); $this->pages->update($page, $request->except(['_method', '_token']));
return redirect()->route('admin.pages.index')->withFlashSuccess(trans('alerts.backend.pages.updated')); return redirect()->route('admin.pages.index')->withFlashSuccess(trans('alerts.backend.pages.updated'));
} }
/** /**
* @param Page $page * @param \App\Models\Page\Page $page
* @param DeletePageRequest $request * @param \App\Http\Requests\Backend\Pages\DeletePageRequest $request
* *
* @return mixed * @return mixed
*/ */
......
...@@ -36,11 +36,7 @@ class PagesTableController extends Controller ...@@ -36,11 +36,7 @@ class PagesTableController extends Controller
return Datatables::of($this->pages->getForDataTable()) return Datatables::of($this->pages->getForDataTable())
->escapeColumns(['title']) ->escapeColumns(['title'])
->addColumn('status', function ($pages) { ->addColumn('status', function ($pages) {
if ($pages->status) { return $pages->status_label;
return '<span class="label label-success">Active</span>';
}
return '<span class="label label-danger">Inactive</span>';
}) })
->addColumn('created_at', function ($pages) { ->addColumn('created_at', function ($pages) {
return Carbon::parse($pages->created_at)->toDateString(); return Carbon::parse($pages->created_at)->toDateString();
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
namespace App\Http; namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel; use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Tymon\JWTAuth\Middleware\GetUserFromToken;
use Tymon\JWTAuth\Middleware\RefreshToken;
/** /**
* Class Kernel. * Class Kernel.
...@@ -73,8 +75,7 @@ class Kernel extends HttpKernel ...@@ -73,8 +75,7 @@ class Kernel extends HttpKernel
*/ */
'access.routeNeedsRole' => \App\Http\Middleware\RouteNeedsRole::class, 'access.routeNeedsRole' => \App\Http\Middleware\RouteNeedsRole::class,
'access.routeNeedsPermission' => \App\Http\Middleware\RouteNeedsPermission::class, 'access.routeNeedsPermission' => \App\Http\Middleware\RouteNeedsPermission::class,
//'jwt.auth' => \App\Http\Middleware\VerifyJWTToken::class, 'jwt.auth' => GetUserFromToken::class,
'jwt.auth' => \Tymon\JWTAuth\Middleware\GetUserFromToken::class, 'jwt.refresh' => RefreshToken::class,
'jwt.refresh' => \Tymon\JWTAuth\Middleware\RefreshToken::class,
]; ];
} }
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\Resource;
class UserResource extends Resource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
*
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'email' => $this->email,
'role' => $this->roles()->first()->name,
'registered_at' => $this->created_at->toIso8601String(),
];
}
}
...@@ -10,11 +10,12 @@ use App\Models\Access\User\Traits\UserSendPasswordReset; ...@@ -10,11 +10,12 @@ use App\Models\Access\User\Traits\UserSendPasswordReset;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
use Tymon\JWTAuth\Contracts\JWTSubject;
/** /**
* Class User. * Class User.
*/ */
class User extends Authenticatable class User extends Authenticatable implements JWTSubject
{ {
use UserScope, use UserScope,
UserAccess, UserAccess,
...@@ -67,4 +68,24 @@ class User extends Authenticatable ...@@ -67,4 +68,24 @@ class User extends Authenticatable
parent::__construct($attributes); parent::__construct($attributes);
$this->table = config('access.users_table'); $this->table = config('access.users_table');
} }
/**
* Get the identifier that will be stored in the subject claim of the JWT.
*
* @return mixed
*/
public function getJWTIdentifier()
{
return $this->getKey();
}
/**
* Return a key value array, containing any custom claims to be added to the JWT.
*
* @return array
*/
public function getJWTCustomClaims()
{
return [];
}
} }
...@@ -16,6 +16,6 @@ class EmailTemplatePlaceholder extends BaseModel ...@@ -16,6 +16,6 @@ class EmailTemplatePlaceholder extends BaseModel
public function __construct(array $attributes = []) public function __construct(array $attributes = [])
{ {
parent::__construct($attributes); parent::__construct($attributes);
$this->table = config('access.email_template_placeholders_table'); $this->table = config('module.email_templates.placeholders_table');
} }
} }
...@@ -16,6 +16,6 @@ class EmailTemplateType extends BaseModel ...@@ -16,6 +16,6 @@ class EmailTemplateType extends BaseModel
public function __construct(array $attributes = []) public function __construct(array $attributes = [])
{ {
parent::__construct($attributes); parent::__construct($attributes);
$this->table = config('access.email_template_types_table'); $this->table = config('module.email_templates.types_table');
} }
} }
...@@ -15,6 +15,8 @@ class EmailTemplate extends BaseModel ...@@ -15,6 +15,8 @@ class EmailTemplate extends BaseModel
// EmailTemplateAttribute::getEditButtonAttribute insteadof ModelTrait; // EmailTemplateAttribute::getEditButtonAttribute insteadof ModelTrait;
} }
protected $guarded = ['id'];
/** /**
* The database table used by the model. * The database table used by the model.
* *
...@@ -25,6 +27,6 @@ class EmailTemplate extends BaseModel ...@@ -25,6 +27,6 @@ class EmailTemplate extends BaseModel
public function __construct(array $attributes = []) public function __construct(array $attributes = [])
{ {
parent::__construct($attributes); parent::__construct($attributes);
$this->table = config('access.email_templates_table'); $this->table = config('module.email_templates.table');
} }
} }
...@@ -14,4 +14,24 @@ trait EmailTemplateAttribute ...@@ -14,4 +14,24 @@ trait EmailTemplateAttribute
{ {
return '<div class="btn-group action-btn">'.$this->getEditButtonAttribute('edit-email-template', 'admin.emailtemplates.edit').'</div>'; return '<div class="btn-group action-btn">'.$this->getEditButtonAttribute('edit-email-template', 'admin.emailtemplates.edit').'</div>';
} }
/**
* @return string
*/
public function getStatusLabelAttribute()
{
if ($this->isActive()) {
return "<label class='label label-success'>".trans('labels.general.active').'</label>';
}
return "<label class='label label-danger'>".trans('labels.general.inactive').'</label>';
}
/**
* @return bool
*/
public function isActive()
{
return $this->status == 1;
}
} }
...@@ -22,9 +22,16 @@ class Page extends BaseModel ...@@ -22,9 +22,16 @@ class Page extends BaseModel
*/ */
protected $table; protected $table;
/**
* The guarded field which are not mass assignable.
*
* @var array
*/
protected $guarded = ['id'];
public function __construct(array $attributes = []) public function __construct(array $attributes = [])
{ {
parent::__construct($attributes); parent::__construct($attributes);
$this->table = config('access.cms_pages_table'); $this->table = config('module.pages.table');
} }
} }
...@@ -17,4 +17,24 @@ trait PageAttribute ...@@ -17,4 +17,24 @@ trait PageAttribute
'.$this->getDeleteButtonAttribute('delete-cms-pages', 'admin.pages.destroy').' '.$this->getDeleteButtonAttribute('delete-cms-pages', 'admin.pages.destroy').'
</div>'; </div>';
} }
/**
* @return string
*/
public function getStatusLabelAttribute()
{
if ($this->isActive()) {
return "<label class='label label-success'>".trans('labels.general.active').'</label>';
}
return "<label class='label label-danger'>".trans('labels.general.inactive').'</label>';
}
/**
* @return bool
*/
public function isActive()
{
return $this->status == 1;
}
} }
<?php
namespace App\Repositories\Api\CmsPage;
use App\Exceptions\GeneralException;
use App\Models\CMSPages\CMSPage;
use App\Repositories\BaseRepository;
/**
* Class CmsPageRepository.
*/
class CmsPageRepository extends BaseRepository
{
/**
* Associated Repository Model.
*/
const MODEL = CMSPage::class;
/**
* Check given user is exist or not.
*
* @return mixed
*/
public function findBySlug($page_slug)
{
if (count($this->query()->wherePage_slug($page_slug)->get()) > 0) {
return $this->query()->wherePage_slug($page_slug)->get()->toArray();
}
throw new GeneralException(trans('exceptions.api.cmspage.not_found'));
}
}
<?php
namespace App\Repositories\Api\Role;
use App\Models\Access\Role\Role;
use App\Repositories\BaseRepository;
/**
* Class RoleRepository.
*/
class RoleRepository extends BaseRepository
{
/**
* Associated Repository Model.
*/
const MODEL = Role::class;
/**
* @return mixed
*/
public function getDefaultUserRole()
{
if (is_numeric(config('access.users.default_role'))) {
return $this->query()->where('id', (int) config('access.users.default_role'))->first();
}
return $this->query()->where('name', config('access.users.default_role'))->first();
}
}
<?php
namespace App\Repositories\Api\User;
use App\Models\Access\PasswordReset\PasswordReset;
use App\Repositories\BaseRepository;
/**
* Class PermissionRepository.
*/
class PasswordResetRepository extends BaseRepository
{
/**
* Associated Repository Model.
*/
const MODEL = PasswordReset::class;
/**
* Get token by email.
*
* @return mixed
*/
public function getByEmail($email)
{
return $this->query()->where('email', $email)->get()->toArray();
}
/**
* Check if given email exist or not.
*
* @return mixed
*/
public function checkUser($data)
{
return $this->query()->where('email', $data['email'])->where('token', $data['token'])->get()->toArray();
}
/**
* Create password reset entry.
*
* @return mixed
*/
public function create($attributes)
{
return $this->query()->insert($attributes);
}
/**
* If token exist for same user then update.
*
* @return mixed
*/
public function update($attributes)
{
$token = ['token' => $attributes['token']];
return $this->query()->where('email', $attributes['email'])->update($attributes);
}
/**
* Delete entry after reseting the password.
*
* @return mixed
*/
public function delete($data)
{
return $this->query()->where('email', $data['email'])->where('token', $data['token'])->delete();
}
}
<?php
namespace App\Repositories\Api\User;
use App\Mail\ConfirmAcoountMail;
use App\Models\Access\User\User;
use App\Repositories\Backend\Access\Role\RoleRepository;
use App\Repositories\BaseRepository;
/**
* Class PermissionRepository.
*/
class UserRepository extends BaseRepository
{
/**
* Associated Repository Model.
*/
const MODEL = User::class;
/**
* Protected rolerepository.
*/
protected $role;
/**
* @param RoleRepository $role
*/
public function __construct(RoleRepository $role)
{
$this->role = $role;
}
/**
* Check given user is exist or not.
*
* @return mixed
*/
public function checkUser($email)
{
return $this->query()->where('email', $email)->get()->toArray();
}
/**
* Generate OTP when forgot password.
*
* @return mixed
*/
public function generateOTP()
{
return mt_rand(100000, 999999);
}
/**
* Reset password.
*
* @return mixed
*/
public function resetpassword($data)
{
$pass = ['password' => bcrypt($data['password'])];
return $this->query()->where('email', $data['email'])->update($pass);
}
/**
* Get user details by id.
*
* @return mixed
*/
public function getById($id)
{
return $this->query()
->select('first_name', 'last_name', 'email', 'address', 'country_id', 'state_id', 'city_id', 'zip_code', 'ssn', 'status', 'created_at', 'updated_at')
->where('id', $id)
->with(['country' => function ($query) {
$query->select('id', 'country');
}])
->with(['state' => function ($query) {
$query->select('id', 'state');
}])
->with(['city' => function ($query) {
$query->select('id', 'city');
}])
->get()
->toArray();
}
/**
* Create user account.
*
* @param array $data
* @param bool $provider
*
* @return static
*/
public function create(array $data, $provider = false)
{
$otp = $this->generateOTP();
$user = self::MODEL;
$user = new $user();
$user->first_name = $data['first_name'];
$user->last_name = $data['last_name'];
$user->address = $data['address'];
$user->state_id = $data['state_id'];
$user->country_id = config('access.constants.default_country');
$user->city_id = $data['city_id'];
$user->zip_code = $data['zip_code'];
$user->ssn = $data['ssn'];
$user->email = $data['email'];
$user->confirmation_code = md5($otp);
$user->status = 1;
$user->password = $provider ? null : bcrypt($data['password']);
$user->confirmed = $provider ? 1 : (config('access.users.confirm_email') ? 0 : 1);
$user->created_by = 1;
\DB::transaction(function () use ($user) {
if ($user->save()) {
/*
* Add the default site role to the new user
*/
$user->attachRole($this->role->getDefaultUserRole());
}
});
/*
* If users have to confirm their email and this is not a social account,
* send the confirmation email
*
* If this is a social account they are confirmed through the social provider by default
*/
if (config('access.users.confirm_email') && $provider === false) {
$Confirmation_mail = \Mail::to($data['email'])->send(new ConfirmAcoountMail($otp));
}
/*
* Return the user object
*/
return $user;
}
/*
* Check user is already confirmed or not
*/
public function checkconfirmation($email)
{
return $this->query()->where('email', $email)->get()->toArray();
}
/**
* Confirm user's account.
**/
public function confirmUser($email)
{
$confirmed = ['confirmed' => '1'];
return $this->query()->where('email', $email)->update($confirmed);
}
}
...@@ -7,7 +7,6 @@ use App\Events\Backend\EmailTemplates\EmailTemplateUpdated; ...@@ -7,7 +7,6 @@ use App\Events\Backend\EmailTemplates\EmailTemplateUpdated;
use App\Exceptions\GeneralException; use App\Exceptions\GeneralException;
use App\Models\EmailTemplates\EmailTemplate; use App\Models\EmailTemplates\EmailTemplate;
use App\Repositories\BaseRepository; use App\Repositories\BaseRepository;
use DB;
/** /**
* Class EmailTemplatesRepository. * Class EmailTemplatesRepository.
...@@ -26,60 +25,53 @@ class EmailTemplatesRepository extends BaseRepository ...@@ -26,60 +25,53 @@ class EmailTemplatesRepository extends BaseRepository
{ {
return $this->query() return $this->query()
->select([ ->select([
config('access.email_templates_table').'.id', config('module.email_templates.table').'.id',
config('access.email_templates_table').'.title', config('module.email_templates.table').'.title',
config('access.email_templates_table').'.subject', config('module.email_templates.table').'.subject',
config('access.email_templates_table').'.status', config('module.email_templates.table').'.status',
config('access.email_templates_table').'.created_at', config('module.email_templates.table').'.created_at',
config('access.email_templates_table').'.updated_at', config('module.email_templates.table').'.updated_at',
]); ]);
} }
/** /**
* @param Model $permission * @param \App\Models\EmailTemplates\EmailTemplate $emailtemplate
* @param $input * @param $input
* *
* @throws GeneralException * @throws GeneralException
* *
* return bool * return bool
*/ */
public function update(Model $emailtemplate, array $input) public function update(EmailTemplate $emailtemplate, array $input)
{ {
$emailtemplate->title = $input['title']; $input['status'] = isset($input['is_active']) ? 1 : 0;
$emailtemplate->body = $input['body']; unset($input['is_active']);
$emailtemplate->type_id = $input['type_id']; $input['updated_by'] = access()->user()->id;
$emailtemplate->subject = $input['subject'];
$emailtemplate->status = (isset($input['is_active']) && $input['is_active'] == 1) ? 1 : 0;
$emailtemplate->updated_by = access()->user()->id;
DB::transaction(function () use ($emailtemplate, $input) { if ($emailtemplate->update($input)) {
if ($emailtemplate->save()) { event(new EmailTemplateUpdated($emailtemplate));
event(new EmailTemplateUpdated($emailtemplate));
return true; return true;
} }
throw new GeneralException(trans('exceptions.backend.emailtemplates.update_error')); throw new GeneralException(trans('exceptions.backend.emailtemplates.update_error'));
});
} }
/** /**
* @param Model $emailtemplate * @param \App\Models\EmailTemplates\EmailTemplate $emailtemplate
* *
* @throws GeneralException * @throws GeneralException
* *
* @return bool * @return bool
*/ */
public function delete(Model $emailtemplate) public function delete(EmailTemplate $emailtemplate)
{ {
DB::transaction(function () use ($emailtemplate) { if ($emailtemplate->delete()) {
if ($emailtemplate->delete()) { event(new EmailTemplateDeleted($emailtemplate));
event(new EmailTemplateDeleted($emailtemplate));
return true; return true;
} }
throw new GeneralException(trans('exceptions.backend.emailtemplates.delete_error')); throw new GeneralException(trans('exceptions.backend.emailtemplates.delete_error'));
});
} }
} }
...@@ -8,7 +8,6 @@ use App\Events\Backend\Pages\PageUpdated; ...@@ -8,7 +8,6 @@ use App\Events\Backend\Pages\PageUpdated;
use App\Exceptions\GeneralException; use App\Exceptions\GeneralException;
use App\Models\Page\Page; use App\Models\Page\Page;
use App\Repositories\BaseRepository; use App\Repositories\BaseRepository;
use DB;
/** /**
* Class PagesRepository. * Class PagesRepository.
...@@ -27,18 +26,18 @@ class PagesRepository extends BaseRepository ...@@ -27,18 +26,18 @@ class PagesRepository extends BaseRepository
{ {
return $this->query() return $this->query()
->select([ ->select([
config('access.pages_table').'.id', config('module.pages.table').'.id',
config('access.pages_table').'.title', config('module.pages.table').'.title',
config('access.pages_table').'.status', config('module.pages.table').'.status',
config('access.pages_table').'.created_at', config('module.pages.table').'.created_at',
config('access.pages_table').'.updated_at', config('module.pages.table').'.updated_at',
]); ]);
} }
/** /**
* @param array $input * @param array $input
* *
* @throws GeneralException * @throws \App\Exceptions\GeneralException
* *
* @return bool * @return bool
*/ */
...@@ -48,80 +47,63 @@ class PagesRepository extends BaseRepository ...@@ -48,80 +47,63 @@ class PagesRepository extends BaseRepository
throw new GeneralException(trans('exceptions.backend.pages.already_exists')); throw new GeneralException(trans('exceptions.backend.pages.already_exists'));
} }
DB::transaction(function () use ($input) { //Making extra fields
$pages = self::MODEL; $input['page_slug'] = str_slug($input['title']);
$pages = new $pages(); $input['status'] = isset($input['status']) ? 1 : 0;
$pages->title = $input['title']; $input['created_by'] = access()->user()->id;
$pages->page_slug = str_slug($input['title']);
$pages->description = $input['description']; if ($page = Page::create($input)) {
$pages->cannonical_link = $input['cannonical_link']; event(new PageCreated($page));
$pages->seo_title = $input['seo_title'];
$pages->seo_keyword = $input['seo_keyword']; return true;
$pages->seo_description = $input['seo_description']; }
$pages->status = (isset($input['status']) && $input['status'] == 1) ? 1 : 0;
$pages->created_by = access()->user()->id; throw new GeneralException(trans('exceptions.backend.pages.create_error'));
if ($pages->save()) {
event(new PageCreated($pages));
return true;
}
throw new GeneralException(trans('exceptions.backend.pages.create_error'));
});
} }
/** /**
* @param Model $permission * @param \App\Models\Page\Page $page
* @param $input * @param array $input
* *
* @throws GeneralException * @throws \App\Exceptions\GeneralException
* *
* return bool * @return bool
*/ */
public function update(Model $page, array $input) public function update($page, array $input)
{ {
if ($this->query()->where('title', $input['title'])->where('id', '!=', $page->id)->first()) { if ($this->query()->where('title', $input['title'])->where('id', '!=', $page->id)->first()) {
throw new GeneralException(trans('exceptions.backend.pages.already_exists')); throw new GeneralException(trans('exceptions.backend.pages.already_exists'));
} }
$page->title = $input['title'];
$page->page_slug = str_slug($input['title']); //Making extra fields
$page->description = $input['description']; $input['page_slug'] = str_slug($input['title']);
$page->cannonical_link = $input['cannonical_link']; $input['status'] = isset($input['status']) ? 1 : 0;
$page->seo_title = $input['seo_title']; $input['updated_by'] = access()->user()->id;
$page->seo_keyword = $input['seo_keyword'];
$page->seo_description = $input['seo_description']; if ($page->update($input)) {
$page->status = (isset($input['status']) && $input['status'] == 1) ? 1 : 0; event(new PageUpdated($page));
$page->updated_by = access()->user()->id;
return true;
DB::transaction(function () use ($page, $input) { }
if ($page->save()) {
event(new PageUpdated($page)); throw new GeneralException(trans('exceptions.backend.pages.update_error'));
return true;
}
throw new GeneralException(trans('exceptions.backend.pages.update_error'));
});
} }
/** /**
* @param Model $page * @param \App\Models\Page\Page $page
* *
* @throws GeneralException * @throws \App\Exceptions\GeneralException
* *
* @return bool * @return bool
*/ */
public function delete(Model $page) public function delete($page)
{ {
DB::transaction(function () use ($page) { if ($page->delete()) {
if ($page->delete()) { event(new PageDeleted($page));
event(new PageDeleted($page));
return true; return true;
} }
throw new GeneralException(trans('exceptions.backend.pages.delete_error')); throw new GeneralException(trans('exceptions.backend.pages.delete_error'));
});
} }
} }
...@@ -15,6 +15,28 @@ class BaseRepository ...@@ -15,6 +15,28 @@ class BaseRepository
return $this->query()->get(); return $this->query()->get();
} }
/**
* Get Paginated.
*
* @param $per_page
* @param string $active
* @param string $order_by
* @param string $sort
*
* @return mixed
*/
public function getPaginated($per_page, $active = '', $order_by = 'id', $sort = 'asc')
{
if ($active) {
return $this->query()->where('status', $active)
->orderBy($order_by, $sort)
->paginate($per_page);
} else {
return $this->query()->orderBy($order_by, $sort)
->paginate($per_page);
}
}
/** /**
* @return mixed * @return mixed
*/ */
......
...@@ -11,6 +11,7 @@ use App\Repositories\Backend\Access\Role\RoleRepository; ...@@ -11,6 +11,7 @@ use App\Repositories\Backend\Access\Role\RoleRepository;
use App\Repositories\BaseRepository; use App\Repositories\BaseRepository;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/** /**
* Class UserRepository. * Class UserRepository.
...@@ -95,7 +96,6 @@ class UserRepository extends BaseRepository ...@@ -95,7 +96,6 @@ class UserRepository extends BaseRepository
$user->password = $provider ? null : bcrypt($data['password']); $user->password = $provider ? null : bcrypt($data['password']);
$user->confirmed = $provider ? 1 : (config('access.users.confirm_email') ? 0 : 1); $user->confirmed = $provider ? 1 : (config('access.users.confirm_email') ? 0 : 1);
$user->is_term_accept = $data['is_term_accept']; $user->is_term_accept = $data['is_term_accept'];
$user->created_by = 1;
DB::transaction(function () use ($user) { DB::transaction(function () use ($user) {
if ($user->save()) { if ($user->save()) {
...@@ -287,4 +287,21 @@ class UserRepository extends BaseRepository ...@@ -287,4 +287,21 @@ class UserRepository extends BaseRepository
throw new GeneralException(trans('exceptions.frontend.auth.password.change_mismatch')); throw new GeneralException(trans('exceptions.frontend.auth.password.change_mismatch'));
} }
/**
* Create a new token for the user.
*
* @return string
*/
public function saveToken()
{
$token = hash_hmac('sha256', Str::random(40), 'hashKey');
\DB::table('password_resets')->insert([
'email' => request('email'),
'token' => $token,
]);
return $token;
}
} }
This diff is collapsed.
...@@ -60,26 +60,6 @@ return [ ...@@ -60,26 +60,6 @@ return [
*/ */
'cities_table' => 'cities', 'cities_table' => 'cities',
/*
* cmspages table used to store cmspages
*/
'pages_table' => 'pages',
/*
* email template placeholders table used to store email template placeholders
*/
'email_template_placeholders_table' => 'email_template_placeholders',
/*
* email template types table used to store email template types
*/
'email_template_types_table' => 'email_template_types',
/*
* Email templates table used to store Email templates
*/
'email_templates_table' => 'email_templates',
/* /*
* Email templates table used to store Email templates * Email templates table used to store Email templates
*/ */
......
<?php <?php
return [ return [
/* // these options are related to the sign-up procedure
|-------------------------------------------------------------------------- 'register' => [
| Standards Tree
|--------------------------------------------------------------------------
|
| Versioning an API with Dingo revolves around content negotiation and
| custom MIME types. A custom type will belong to one of three
| standards trees, the Vendor tree (vnd), the Personal tree
| (prs), and the Unregistered tree (x).
|
| By default the Unregistered tree (x) is used, however, should you wish
| to you can register your type with the IANA. For more details:
| https://tools.ietf.org/html/rfc6838
|
*/
'standardsTree' => env('API_STANDARDS_TREE', 'x'),
/*
|--------------------------------------------------------------------------
| API Subtype
|--------------------------------------------------------------------------
|
| Your subtype will follow the standards tree you use when used in the
| "Accept" header to negotiate the content type and version.
|
| For example: Accept: application/x.SUBTYPE.v1+json
|
*/
'subtype' => env('API_SUBTYPE', ''),
/*
|--------------------------------------------------------------------------
| Default API Version
|--------------------------------------------------------------------------
|
| This is the default version when strict mode is disabled and your API
| is accessed via a web browser. It's also used as the default version
| when generating your APIs documentation.
|
*/
'version' => env('API_VERSION', 'v1'),
/*
|--------------------------------------------------------------------------
| Default API Prefix
|--------------------------------------------------------------------------
|
| A default prefix to use for your API routes so you don't have to
| specify it for each group.
|
*/
'prefix' => env('API_PREFIX', null),
/*
|--------------------------------------------------------------------------
| Default API Domain
|--------------------------------------------------------------------------
|
| A default domain to use for your API routes so you don't have to
| specify it for each group.
|
*/
'domain' => env('API_DOMAIN', null),
/*
|--------------------------------------------------------------------------
| Name
|--------------------------------------------------------------------------
|
| When documenting your API using the API Blueprint syntax you can
| configure a default name to avoid having to manually specify
| one when using the command.
|
*/
'name' => env('API_NAME', null),
/*
|--------------------------------------------------------------------------
| Conditional Requests
|--------------------------------------------------------------------------
|
| Globally enable conditional requests so that an ETag header is added to
| any successful response. Subsequent requests will perform a check and
| will return a 304 Not Modified. This can also be enabled or disabled
| on certain groups or routes.
|
*/
'conditionalRequest' => env('API_CONDITIONAL_REQUEST', true),
/*
|--------------------------------------------------------------------------
| Strict Mode
|--------------------------------------------------------------------------
|
| Enabling strict mode will require clients to send a valid Accept header
| with every request. This also voids the default API version, meaning
| your API will not be browsable via a web browser.
|
*/
'strict' => env('API_STRICT', false),
/*
|--------------------------------------------------------------------------
| Debug Mode
|--------------------------------------------------------------------------
|
| Enabling debug mode will result in error responses caused by thrown
| exceptions to have a "debug" key that will be populated with
| more detailed information on the exception.
|
*/
'debug' => env('API_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Generic Error Format
|--------------------------------------------------------------------------
|
| When some HTTP exceptions are not caught and dealt with the API will
| generate a generic error response in the format provided. Any
| keys that aren't replaced with corresponding values will be
| removed from the final response.
|
*/
'errorFormat' => [
'message' => ':message',
'errors' => ':errors',
'code' => ':code',
'status_code' => ':status_code',
'debug' => ':debug',
],
/*
|--------------------------------------------------------------------------
| API Middleware
|--------------------------------------------------------------------------
|
| Middleware that will be applied globally to all API requests.
|
*/
'middleware' => [
// this option must be set to true if you want to release a token
// when your user successfully terminates the sign-in procedure
'release_token' => env('SIGN_UP_RELEASE_TOKEN', true),
], ],
/* // these options are related to the password recovery procedure
|-------------------------------------------------------------------------- 'reset_password' => [
| Authentication Providers
|--------------------------------------------------------------------------
|
| The authentication providers that should be used when attempting to
| authenticate an incoming API request.
|
*/
'auth' => [
'jwt' => 'Dingo\Api\Auth\Provider\JWT',
],
/*
|--------------------------------------------------------------------------
| Throttling / Rate Limiting
|--------------------------------------------------------------------------
|
| Consumers of your API can be limited to the amount of requests they can
| make. You can create your own throttles or simply change the default
| throttles.
|
*/
'throttling' => [
],
/*
|--------------------------------------------------------------------------
| Response Transformer
|--------------------------------------------------------------------------
|
| Responses can be transformed so that they are easier to format. By
| default a Fractal transformer will be used to transform any
| responses prior to formatting. You can easily replace
| this with your own transformer.
|
*/
'transformer' => env('API_TRANSFORMER', Dingo\Api\Transformer\Adapter\Fractal::class),
/*
|--------------------------------------------------------------------------
| Response Formats
|--------------------------------------------------------------------------
|
| Responses can be returned in multiple formats by registering different
| response formatters. You can also customize an existing response
| formatter.
|
*/
'defaultFormat' => env('API_DEFAULT_FORMAT', 'json'),
'formats' => [
'json' => Dingo\Api\Http\Response\Format\Json::class,
// this option must be set to true if you want to release a token
// when your user successfully terminates the password reset procedure
'release_token' => env('PASSWORD_RESET_RELEASE_TOKEN', false),
], ],
]; ];
<?php
return [
/*
* Validation rules for all api.
*/
'login' => [
'rules' => [
'email' => 'required|email',
'password' => 'required',
],
],
'forgotpassword' => [
'rules' => [
'email' => 'required|email',
],
],
'resetpassword' => [
'rules' => [
'email' => 'required|email',
'password_confirmation' => 'required',
'password' => 'required|confirmed',
'token' => 'required',
],
],
'register' => [
'rules' => [
'first_name' => 'required|max:255',
'last_name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
'state_id' => 'required',
'city_id' => 'required',
'zip_code' => 'required',
'ssn' => 'required',
],
],
'confirmaccount' => [
'rules' => [
'email' => 'required|email',
'otp' => 'required',
],
],
];
...@@ -44,7 +44,7 @@ return [ ...@@ -44,7 +44,7 @@ return [
], ],
'api' => [ 'api' => [
'driver' => 'token', 'driver' => 'jwt',
'provider' => 'users', 'provider' => 'users',
], ],
], ],
......
...@@ -50,8 +50,17 @@ return [ ...@@ -50,8 +50,17 @@ return [
'charset' => 'utf8mb4', 'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci', 'collation' => 'utf8mb4_unicode_ci',
'prefix' => '', 'prefix' => '',
'strict' => true, 'strict' => false, //If you set strict to true, then make sure to enable which modes you want to enable by looking at 'modes' key in this config
'engine' => null, 'engine' => null,
'modes' => [
// "ONLY_FULL_GROUP_BY",
// "STRICT_TRANS_TABLES",
// "NO_ZERO_IN_DATE",
// "NO_ZERO_DATE",
// "ERROR_FOR_DIVISION_BY_ZERO",
// "NO_AUTO_CREATE_USER",
// "NO_ENGINE_SUBSTITUTION",
],
], ],
'pgsql' => [ 'pgsql' => [
......
...@@ -16,12 +16,74 @@ return [ ...@@ -16,12 +16,74 @@ return [
| JWT Authentication Secret | JWT Authentication Secret
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Don't forget to set this, as it will be used to sign your tokens. | Don't forget to set this in your .env file, as it will be used to sign
| A helper command is provided for this: `php artisan jwt:generate` | your tokens. A helper command is provided for this:
| `php artisan jwt:secret`
|
| Note: This will be used for Symmetric algorithms only (HMAC),
| since RSA and ECDSA use a private/public key combo (See below).
| |
*/ */
'secret' => env('JWT_SECRET', '3M0tGfsEolZsrst5wrJgUOWk5Zkqzx5A'), 'secret' => env('JWT_SECRET'),
/*
|--------------------------------------------------------------------------
| JWT Authentication Keys
|--------------------------------------------------------------------------
|
| The algorithm you are using, will determine whether your tokens are
| signed with a random string (defined in `JWT_SECRET`) or using the
| following public & private keys.
|
| Symmetric Algorithms:
| HS256, HS384 & HS512 will use `JWT_SECRET`.
|
| Asymmetric Algorithms:
| RS256, RS384 & RS512 / ES256, ES384 & ES512 will use the keys below.
|
*/
'keys' => [
/*
|--------------------------------------------------------------------------
| Public Key
|--------------------------------------------------------------------------
|
| A path or resource to your public key.
|
| E.g. 'file://path/to/public/key'
|
*/
'public' => env('JWT_PUBLIC_KEY'),
/*
|--------------------------------------------------------------------------
| Private Key
|--------------------------------------------------------------------------
|
| A path or resource to your private key.
|
| E.g. 'file://path/to/private/key'
|
*/
'private' => env('JWT_PRIVATE_KEY'),
/*
|--------------------------------------------------------------------------
| Passphrase
|--------------------------------------------------------------------------
|
| The passphrase for your private key. Can be null if none set.
|
*/
'passphrase' => env('JWT_PASSPHRASE'),
],
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
...@@ -29,11 +91,16 @@ return [ ...@@ -29,11 +91,16 @@ return [
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Specify the length of time (in minutes) that the token will be valid for. | Specify the length of time (in minutes) that the token will be valid for.
| Defaults to 1 hour | Defaults to 1 hour.
|
| You can also set this to null, to yield a never expiring token.
| Some people may want this behaviour for e.g. a mobile app.
| This is not particularly recommended, so make sure you have appropriate
| systems in place to revoke the token if necessary.
| |
*/ */
'ttl' => 60, 'ttl' => env('JWT_TTL', 60),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
...@@ -43,11 +110,16 @@ return [ ...@@ -43,11 +110,16 @@ return [
| Specify the length of time (in minutes) that the token can be refreshed | Specify the length of time (in minutes) that the token can be refreshed
| within. I.E. The user can refresh their token within a 2 week window of | within. I.E. The user can refresh their token within a 2 week window of
| the original token being created until they must re-authenticate. | the original token being created until they must re-authenticate.
| Defaults to 2 weeks | Defaults to 2 weeks.
|
| You can also set this to null, to yield an infinite refresh time.
| Some may want this instead of never expiring tokens for e.g. a mobile app.
| This is not particularly recommended, so make sure you have appropriate
| systems in place to revoke the token if necessary.
| |
*/ */
'refresh_ttl' => 20160, 'refresh_ttl' => env('JWT_REFRESH_TTL', 20160),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
...@@ -56,61 +128,95 @@ return [ ...@@ -56,61 +128,95 @@ return [
| |
| Specify the hashing algorithm that will be used to sign the token. | Specify the hashing algorithm that will be used to sign the token.
| |
| See here: https://github.com/namshi/jose/tree/2.2.0/src/Namshi/JOSE/Signer | See here: https://github.com/namshi/jose/tree/master/src/Namshi/JOSE/Signer/OpenSSL
| for possible values | for possible values.
| |
*/ */
'algo' => 'HS256', 'algo' => env('JWT_ALGO', 'HS256'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| User Model namespace | Required Claims
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Specify the full namespace to your User model. | Specify the required claims that must exist in any token.
| e.g. 'Acme\Entities\User' | A TokenInvalidException will be thrown if any of these claims are not
| present in the payload.
| |
*/ */
'user' => 'App\Models\Access\User\User', 'required_claims' => [
'iss',
'iat',
'exp',
'nbf',
'sub',
'jti',
],
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| User identifier | Persistent Claims
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Specify a unique property of the user that will be added as the 'sub' | Specify the claim keys to be persisted when refreshing a token.
| claim of the token payload. | `sub` and `iat` will automatically be persisted, in
| addition to the these claims.
|
| Note: If a claim does not exist then it will be ignored.
| |
*/ */
'identifier' => 'id', 'persistent_claims' => [
// 'foo',
// 'bar',
],
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Required Claims | Blacklist Enabled
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Specify the required claims that must exist in any token. | In order to invalidate tokens, you must have the blacklist enabled.
| A TokenInvalidException will be thrown if any of these claims are not | If you do not want or need this functionality, then set this to false.
| present in the payload. |
*/
'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true),
/*
| -------------------------------------------------------------------------
| Blacklist Grace Period
| -------------------------------------------------------------------------
|
| When multiple concurrent requests are made with the same JWT,
| it is possible that some of them fail, due to token regeneration
| on every request.
|
| Set grace period in seconds to prevent parallel request failure.
| |
*/ */
'required_claims' => ['iss', 'iat', 'exp', 'nbf', 'sub', 'jti'], 'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Blacklist Enabled | Cookies encryption
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| In order to invalidate tokens, you must have the blacklist enabled. | By default Laravel encrypt cookies for security reason.
| If you do not want or need this functionality, then set this to false. | If you decide to not decrypt cookies, you will have to configure Laravel
| to not encrypt your cookie token by adding its name into the $except
| array available in the middleware "EncryptCookies" provided by Laravel.
| see https://laravel.com/docs/master/responses#cookies-and-encryption
| for details.
|
| Set it to false if you don't want to decrypt cookies.
| |
*/ */
'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true), 'decrypt_cookies' => true,
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
...@@ -123,18 +229,6 @@ return [ ...@@ -123,18 +229,6 @@ return [
'providers' => [ 'providers' => [
/*
|--------------------------------------------------------------------------
| User Provider
|--------------------------------------------------------------------------
|
| Specify the provider that is used to find the user based
| on the subject claim
|
*/
'user' => 'Tymon\JWTAuth\Providers\User\EloquentUserAdapter',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| JWT Provider | JWT Provider
...@@ -144,7 +238,7 @@ return [ ...@@ -144,7 +238,7 @@ return [
| |
*/ */
'jwt' => 'Tymon\JWTAuth\Providers\JWT\NamshiAdapter', 'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class,
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
...@@ -155,18 +249,18 @@ return [ ...@@ -155,18 +249,18 @@ return [
| |
*/ */
'auth' => 'Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter', 'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class,
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Storage Provider | Storage Provider
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Specify the provider that is used to store tokens in the blacklist | Specify the provider that is used to store tokens in the blacklist.
| |
*/ */
'storage' => 'Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter', 'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class,
], ],
......
<?php
return [
/*
|--------------------------------------------------------------------------
| Routing
|--------------------------------------------------------------------------
*/
// Include to pre-defined routes from package or not. Middlewares
'use_package_routes' => true,
// Middlewares which should be applied to all package routes.
// For laravel 5.1 and before, remove 'web' from the array.
'middlewares' => ['web', 'auth'],
// The url to this package. Change it if necessary.
'url_prefix' => 'laravel-filemanager',
/*
|--------------------------------------------------------------------------
| Multi-User Mode
|--------------------------------------------------------------------------
*/
// If true, private folders will be created for each signed-in user.
'allow_multi_user' => true,
// If true, share folder will be created when allow_multi_user is true.
'allow_share_folder' => true,
// Flexible way to customize client folders accessibility
// If you want to customize client folders, publish tag="lfm_handler"
// Then you can rewrite userField function in App\Handler\ConfigHander class
// And set 'user_field' to App\Handler\ConfigHander::class
// Ex: The private folder of user will be named as the user id.
'user_field' => Unisharp\Laravelfilemanager\Handlers\ConfigHandler::class,
/*
|--------------------------------------------------------------------------
| Working Directory
|--------------------------------------------------------------------------
*/
// Which folder to store files in project, fill in 'public', 'resources', 'storage' and so on.
// You should create routes to serve images if it is not set to public.
'base_directory' => 'public',
'images_folder_name' => 'photos',
'files_folder_name' => 'files',
'shared_folder_name' => 'shares',
'thumb_folder_name' => 'thumbs',
/*
|--------------------------------------------------------------------------
| Startup Views
|--------------------------------------------------------------------------
*/
// The default display type for items.
// Supported: "grid", "list"
'images_startup_view' => 'grid',
'files_startup_view' => 'list',
/*
|--------------------------------------------------------------------------
| Upload / Validation
|--------------------------------------------------------------------------
*/
// If true, the uploaded file will be renamed to uniqid() + file extension.
'rename_file' => false,
// If rename_file set to false and this set to true, then non-alphanumeric characters in filename will be replaced.
'alphanumeric_filename' => false,
// If true, non-alphanumeric folder name will be rejected.
'alphanumeric_directory' => false,
// If true, the uploading file's size will be verified for over than max_image_size/max_file_size.
'should_validate_size' => false,
'max_image_size' => 50000,
'max_file_size' => 50000,
// If true, the uploading file's mime type will be valid in valid_image_mimetypes/valid_file_mimetypes.
'should_validate_mime' => false,
// available since v1.3.0
'valid_image_mimetypes' => [
'image/jpeg',
'image/pjpeg',
'image/png',
'image/gif',
'image/svg+xml',
],
// If true, image thumbnails would be created during upload
'should_create_thumbnails' => true,
// Create thumbnails automatically only for listed types.
'raster_mimetypes' => [
'image/jpeg',
'image/pjpeg',
'image/png',
],
// permissions to be set when create a new folder or when it creates automatically with thumbnails
'create_folder_mode' => 0755,
// permissions to be set on file upload.
'create_file_mode' => 0644,
// available since v1.3.0
// only when '/laravel-filemanager?type=Files'
'valid_file_mimetypes' => [
'image/jpeg',
'image/pjpeg',
'image/png',
'image/gif',
'image/svg+xml',
'application/pdf',
'text/plain',
],
/*
|--------------------------------------------------------------------------
| Image / Folder Setting
|--------------------------------------------------------------------------
*/
'thumb_img_width' => 200,
'thumb_img_height' => 200,
/*
|--------------------------------------------------------------------------
| File Extension Information
|--------------------------------------------------------------------------
*/
'file_type_array' => [
'pdf' => 'Adobe Acrobat',
'doc' => 'Microsoft Word',
'docx' => 'Microsoft Word',
'xls' => 'Microsoft Excel',
'xlsx' => 'Microsoft Excel',
'zip' => 'Archive',
'gif' => 'GIF Image',
'jpg' => 'JPEG Image',
'jpeg' => 'JPEG Image',
'png' => 'PNG Image',
'ppt' => 'Microsoft PowerPoint',
'pptx' => 'Microsoft PowerPoint',
],
'file_icon_array' => [
'pdf' => 'fa-file-pdf-o',
'doc' => 'fa-file-word-o',
'docx' => 'fa-file-word-o',
'xls' => 'fa-file-excel-o',
'xlsx' => 'fa-file-excel-o',
'zip' => 'fa-file-archive-o',
'gif' => 'fa-file-image-o',
'jpg' => 'fa-file-image-o',
'jpeg' => 'fa-file-image-o',
'png' => 'fa-file-image-o',
'ppt' => 'fa-file-powerpoint-o',
'pptx' => 'fa-file-powerpoint-o',
],
/*
|--------------------------------------------------------------------------
| php.ini override
|--------------------------------------------------------------------------
|
| These values override your php.ini settings before uploading files
| Set these to false to ingnore and apply your php.ini settings
|
| Please note that the 'upload_max_filesize' & 'post_max_size'
| directives are not supported.
*/
'php_ini_overrides' => [
'memory_limit' => '256M',
],
];
<?php
return [
'pages' => [
'table' => 'pages',
],
'email_templates'=> [
'table' => 'email_templates',
'placeholders_table' => 'email_template_placeholders',
'types_table' => 'email_template_types',
],
];
...@@ -14,7 +14,7 @@ class EmailTemplatePlaceholderTableSeeder extends Seeder ...@@ -14,7 +14,7 @@ class EmailTemplatePlaceholderTableSeeder extends Seeder
public function run() public function run()
{ {
if (env('DB_CONNECTION') == 'mysql') { if (env('DB_CONNECTION') == 'mysql') {
DB::table(config('access.email_template_placeholders_table'))->truncate(); DB::table(config('module.email_templates.placeholders_table'))->truncate();
} }
$data = [ $data = [
...@@ -75,6 +75,6 @@ class EmailTemplatePlaceholderTableSeeder extends Seeder ...@@ -75,6 +75,6 @@ class EmailTemplatePlaceholderTableSeeder extends Seeder
], ],
]; ];
DB::table(config('access.email_template_placeholders_table'))->insert($data); DB::table(config('module.email_templates.placeholders_table'))->insert($data);
} }
} }
...@@ -14,7 +14,7 @@ class EmailTemplateTableSeeder extends Seeder ...@@ -14,7 +14,7 @@ class EmailTemplateTableSeeder extends Seeder
public function run() public function run()
{ {
if (env('DB_CONNECTION') == 'mysql') { if (env('DB_CONNECTION') == 'mysql') {
DB::table(config('access.email_templates_table'))->truncate(); DB::table(config('module.email_templates.table'))->truncate();
} }
$data = [ $data = [
...@@ -285,6 +285,6 @@ class EmailTemplateTableSeeder extends Seeder ...@@ -285,6 +285,6 @@ class EmailTemplateTableSeeder extends Seeder
], ],
]; ];
DB::table(config('access.email_templates_table'))->insert($data); DB::table(config('module.email_templates.table'))->insert($data);
} }
} }
...@@ -14,7 +14,7 @@ class EmailTemplateTypeTableSeeder extends Seeder ...@@ -14,7 +14,7 @@ class EmailTemplateTypeTableSeeder extends Seeder
public function run() public function run()
{ {
if (env('DB_CONNECTION') == 'mysql') { if (env('DB_CONNECTION') == 'mysql') {
DB::table(config('access.email_template_types_table'))->truncate(); DB::table(config('module.email_templates.types_table'))->truncate();
} }
$data = [ $data = [
...@@ -43,6 +43,6 @@ class EmailTemplateTypeTableSeeder extends Seeder ...@@ -43,6 +43,6 @@ class EmailTemplateTypeTableSeeder extends Seeder
], ],
]; ];
DB::table(config('access.email_template_types_table'))->insert($data); DB::table(config('module.email_templates.types_table'))->insert($data);
} }
} }
...@@ -18,7 +18,7 @@ class PagesTableSeeder extends Seeder ...@@ -18,7 +18,7 @@ class PagesTableSeeder extends Seeder
public function run() public function run()
{ {
$this->disableForeignKeys(); $this->disableForeignKeys();
$this->truncate(config('access.pages_table')); $this->truncate(config('module.pages.table'));
$page = [ $page = [
[ [
...@@ -32,7 +32,7 @@ class PagesTableSeeder extends Seeder ...@@ -32,7 +32,7 @@ class PagesTableSeeder extends Seeder
], ],
]; ];
DB::table(config('access.pages_table'))->insert($page); DB::table(config('module.pages.table'))->insert($page);
$this->enableForeignKeys(); $this->enableForeignKeys();
} }
......
{ {
"/js/frontend.js": "/js/frontend.70ee44a92d84e7318a9d.js", "/js/frontend.js": "/js/frontend.d3a9d9963b6da237bfe8.js",
"/js/backend.js": "/js/backend.9cdae6ab449e701ce881.js", "/js/backend.js": "/js/backend.51a14fd841ccd198e500.js",
"/mix.js": "/mix.247ab120fe7680658924.js", "/mix.js": "/mix.247ab120fe7680658924.js",
"/css/frontend.css": "/css/frontend.3af0a6cbd7d1d8d042f2a37e97008b7c.css", "/css/frontend.css": "/css/frontend.3af0a6cbd7d1d8d042f2a37e97008b7c.css",
"/css/backend.css": "/css/backend.f8550f50504e5b8ef6055285205f223a.css", "/css/backend.css": "/css/backend.f8550f50504e5b8ef6055285205f223a.css",
"/css/backend-custom.css": "/css/backend-custom.50f14193ab908e3cf471dea6cb6616ae.css", "/css/backend-custom.css": "/css/backend-custom.50f14193ab908e3cf471dea6cb6616ae.css",
"/js/backend-custom.js": "/js/backend-custom.694670b0d97bf54111bac3bd91ba3fcf.js", "/js/backend-custom.js": "/js/backend-custom.69e7d487a5a38a38520a62a5c53584f9.js",
"/js/dataTable.js": "/js/dataTable.f968d300a6a0b871f138f114361259c8.js" "/js/dataTable.js": "/js/dataTable.f968d300a6a0b871f138f114361259c8.js"
} }
\ No newline at end of file
<?php
return [
'messages' => [
'registeration' => [
'success' => 'You have registered successfully. Please check your email for activation!',
],
'login' => [
'success' => 'Login Successfull.',
'failed' => 'Invalid Credentials! Please try again.',
],
'logout' => [
'success' => 'Successfully logged out.',
],
'forgot_password' => [
'success' => 'We have sent email with reset password link. Please check your inbox!.',
'validation' => [
'email_not_found' => 'This email address is not registered.',
],
],
'refresh' => [
'token' => [
'not_provided' => 'Token not provided.',
],
'status' => 'Ok',
],
],
];
...@@ -92,11 +92,11 @@ ...@@ -92,11 +92,11 @@
type: 'post' type: 'post'
}, },
columns: [ columns: [
{data: 'title', name: '{{config('access.email_templates_table')}}.title'}, {data: 'title', name: '{{config('module.email_templates.table')}}.title'},
{data: 'subject', name: '{{config('access.email_templates_table')}}.subject'}, {data: 'subject', name: '{{config('module.email_templates.table')}}.subject'},
{data: 'status', name: '{{config('access.email_templates_table')}}.status'}, {data: 'status', name: '{{config('module.email_templates.table')}}.status'},
{data: 'created_at', name: '{{config('access.email_templates_table')}}.created_at'}, {data: 'created_at', name: '{{config('module.email_templates.table')}}.created_at'},
{data: 'updated_at', name: '{{config('access.email_templates_table')}}.updated_at'}, {data: 'updated_at', name: '{{config('module.email_templates.table')}}.updated_at'},
{data: 'actions', name: 'actions', searchable: false, sortable: false} {data: 'actions', name: 'actions', searchable: false, sortable: false}
], ],
order: [[3, "asc"]], order: [[3, "asc"]],
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<footer class="main-footer"> <footer class="main-footer">
<!-- To the right --> <!-- To the right -->
<div class="pull-right hidden-xs"> <div class="pull-right hidden-xs">
<a href="http://laravel-boilerplate.com" target="_blank">{{ trans('strings.backend.general.boilerplate_link') }}</a> <a href="http://laravel-admin.com" target="_blank">{{ trans('strings.backend.general.boilerplate_link') }}</a>
</div> </div>
<!-- Default to the left --> <!-- Default to the left -->
<strong>Copyright &copy; {{ date('Y') }} <a href="#">{{ app_name() }}</a>.</strong> {{ trans('strings.backend.general.all_rights_reserved') }} <strong>Copyright &copy; {{ date('Y') }} <a href="#">{{ app_name() }}</a>.</strong> {{ trans('strings.backend.general.all_rights_reserved') }}
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
<!-- Meta --> <!-- Meta -->
<meta name="description" content="@yield('meta_description', 'Default Description')"> <meta name="description" content="@yield('meta_description', 'Default Description')">
<meta name="author" content="@yield('meta_author', 'Viral Solani')"> <meta name="author" content="@yield('meta_author', 'Viral Solani')">
<!--Lato Fonts Included--> {{-- <!--Lato Fonts Included-->
<link href="https://fonts.googleapis.com/css?family=Lato:300,300i,400,400i,700,700i,900,900i" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Lato:300,300i,400,400i,700,700i,900,900i" rel="stylesheet"> --}}
@yield('meta') @yield('meta')
<!-- Styles --> <!-- Styles -->
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
<section class="content-header"> <section class="content-header">
@yield('page-header') @yield('page-header')
<!-- Breadcrumbs would render from routes/breadcrumb.php --> <!-- Breadcrumbs would render from routes/breadcrumb.php -->
{!! Breadcrumbs::render() !!}
</section> </section>
<!-- Main content --> <!-- Main content -->
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
@endsection @endsection
@section('content') @section('content')
{{ Form::model($cmspage, ['route' => ['admin.pages.update', $cmspage], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-role']) }} {{ Form::model($page, ['route' => ['admin.pages.update', $page], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-role']) }}
<div class="box box-success"> <div class="box box-success">
<div class="box-header with-border"> <div class="box-header with-border">
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
<div class="col-lg-10"> <div class="col-lg-10">
<div class="control-group"> <div class="control-group">
<label class="control control--checkbox"> <label class="control control--checkbox">
{{ Form::checkbox('status', 1, ($cmspage->status == 1) ? true : false ) }} {{ Form::checkbox('status', 1, ($page->status == 1) ? true : false ) }}
<div class="control__indicator"></div> <div class="control__indicator"></div>
</label> </label>
</div> </div>
......
...@@ -74,10 +74,10 @@ ...@@ -74,10 +74,10 @@
type: 'post' type: 'post'
}, },
columns: [ columns: [
{data: 'title', name: '{{config('access.pages_table')}}.title'}, {data: 'title', name: '{{config('module.pages.table')}}.title'},
{data: 'status', name: '{{config('access.pages_table')}}.status'}, {data: 'status', name: '{{config('module.pages.table')}}.status'},
{data: 'created_at', name: '{{config('access.pages_table')}}.created_at'}, {data: 'created_at', name: '{{config('module.pages.table')}}.created_at'},
{data: 'updated_at', name: '{{config('access.pages_table')}}.updated_at'}, {data: 'updated_at', name: '{{config('module.pages.table')}}.updated_at'},
{data: 'actions', name: 'actions', searchable: false, sortable: false} {data: 'actions', name: 'actions', searchable: false, sortable: false}
], ],
order: [[3, "asc"]], order: [[3, "asc"]],
......
...@@ -20,17 +20,6 @@ Route::any('generateSlug', function (\Illuminate\Http\Request $request) { ...@@ -20,17 +20,6 @@ Route::any('generateSlug', function (\Illuminate\Http\Request $request) {
return str_slug($request['text']); return str_slug($request['text']);
})->name('generate.slug'); })->name('generate.slug');
/*
* Email Templates Management
*/
Route::group(['namespace' => 'EmailTemplates'], function () {
Route::resource('emailtemplates', 'EmailTemplatesController', ['except' => ['show', 'create', 'save']]);
//For DataTables
Route::post('emailtemplates/get', 'EmailTemplatesTableController')
->name('emailtemplates.get');
});
/* /*
* Settings Management * Settings Management
*/ */
......
<?php
/*
* Email Templates Management
*/
Route::group(['namespace' => 'EmailTemplates'], function () {
Route::resource('emailtemplates', 'EmailTemplatesController', ['except' => ['show', 'create', 'save']]);
//For DataTables
Route::post('emailtemplates/get', 'EmailTemplatesTableController')
->name('emailtemplates.get');
});
...@@ -14,13 +14,21 @@ ...@@ -14,13 +14,21 @@
Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], function () { Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], function () {
Route::group(['prefix' => 'auth'], function () { Route::group(['prefix' => 'auth'], function () {
Route::post('/login', 'AuthController@authenticate'); Route::post('register', 'RegisterController@register');
Route::post('/logout', 'AuthController@logout'); Route::post('login', 'AuthController@login');
Route::post('/check', 'AuthController@check'); });
Route::post('/register', 'AuthController@register');
Route::get('/activate/{token}', 'AuthController@activate'); Route::group(['middleware' => ['jwt.auth']], function () {
Route::post('/password', 'AuthController@password'); Route::group(['prefix' => 'auth'], function () {
Route::post('/validate-password-reset', 'AuthController@validatePasswordReset'); Route::post('logout', 'AuthController@logout');
Route::post('/reset', 'AuthController@reset'); Route::post('refresh', 'AuthController@refresh');
// Password Reset Routes
Route::post('password/email', 'ForgotPasswordController@sendResetLinkEmail');
Route::post('password/reset', 'ResetPasswordController@reset')->name('password.reset');
});
// Users
Route::resource('users', 'UsersController');
}); });
}); });
...@@ -23,7 +23,9 @@ abstract class BrowserKitTestCase extends BaseTestCase ...@@ -23,7 +23,9 @@ abstract class BrowserKitTestCase extends BaseTestCase
* *
* @var string * @var string
*/ */
protected $baseUrl = 'http://l5boilerplate.dev'; protected $baseUrl = ' */
*/
http://laraveladminpanel.dev';
/** /**
* @var * @var
...@@ -62,7 +64,9 @@ abstract class BrowserKitTestCase extends BaseTestCase ...@@ -62,7 +64,9 @@ abstract class BrowserKitTestCase extends BaseTestCase
{ {
parent::setUp(); parent::setUp();
$this->baseUrl = config('app.url', 'http://l5boilerplate.dev'); $this->baseUrl = config('app.url', ' */
*/
http://laraveladminpanel.dev');
// Set up the database // Set up the database
Artisan::call('migrate:refresh'); Artisan::call('migrate:refresh');
......
...@@ -19,7 +19,9 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase ...@@ -19,7 +19,9 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
* *
* @var string * @var string
*/ */
protected $baseUrl = 'http://l5boilerplate.dev'; protected $baseUrl = ' */
*/
http://laraveladminpanel.dev';
/** /**
* @var * @var
......
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