Unverified Commit 9ff78f8c authored by Ruchit Patel's avatar Ruchit Patel Committed by GitHub

Merge pull request #4 from viralsolani/master

Pull from master.
parents e9c76589 e685e60d
APP_NAME="Laravel Admin Panel"
APP_SHORT_NAME="LAP"
APP_ENV=local
APP_KEY=base64:O+TrollIDwasHEREtMG9kBc+/Q32exQLusNVhnq558w=
APP_DEBUG=true
......@@ -21,6 +22,11 @@ CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
#Session Timeout
SESSION_TIMEOUT_STATUS=true
#In Seconds
SESSION_TIMEOUT=600
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
......@@ -28,6 +34,8 @@ REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_FROM=viral.solani@gmail.com
MAIL_FROM_NAME=Admin
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
......
......@@ -23,7 +23,15 @@ npm-debug.log
yarn-error.log
phpunit.txt
public/css
public/js
public/js/*.js
public/js/plugins
public/js/skins
public/js/themes
public/vendor
public/js/skins/*.js
composer.lock
public/img/backend/blog_images/*
public/mix-manifest.json
\ No newline at end of file
public/mix-manifest.json
public/access.log
public/error.log
\ No newline at end of file
......@@ -5,16 +5,18 @@
[![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)
## [Demo](https://laravel-adminpanel.vrkansagara.in/)
## Introduction
* This is a laravel Admin Panel, based on [Rappasoft Laravel Boilerplate](https://github.com/rappasoft/laravel-5-boilerplate/releases/tag/4.5.7), with enhancemenets and many modules pre-made, just for you.
* The project is taken to Laravel 5.5 so we can develop from the latest Laravel.
* The project is taken to Laravel 5.6 so we can develop from the latest Laravel.
* Article on our Admin Panel on CodeWall : [https://www.codewall.co.uk/the-laravel-admin-panel-that-you-need/](https://www.codewall.co.uk/the-laravel-admin-panel-that-you-need/)
## Features
For Laravel 5 Boilerplate Features : [Features](https://github.com/rappasoft/laravel-5-boilerplate/wiki#features)
## Additional Features
* Built-in Laravel Boilerplate CRUD Generator,
* Built-in Laravel Boilerplate Module Generator,
* Dynamic Menu/Sidebar Builder
* CMS Pages Module
* Email Template Module
......@@ -24,9 +26,14 @@ For Laravel 5 Boilerplate Features : [Features](https://github.com/rappasoft/lar
Give your project a Head Start by using [laravel-adminpanel](https://github.com/viralsolani/laravel-adminpanel).
## Built-in Laravel Boilerplate Module Generator
It gives you the ability to create a module using a sweet GUI, where you put in the Module Name and it will generate all the necessary files for you, like Model, Traits, Relationship, Migration, Controllers, Views and routes. So when you are done creating a module, you can directly go to the route generated and see your new module. Since, this does not have the ability to generate table fields for now, so you have to write the migration file that is generated and run a manual php artisan migrate command, and you are good to go.
We are using the module generator as a package, you can find it here: [Module Generator For Laravel Adminpanel](https://github.com/bvipul/generator).
## Installation
Please check the official laravel installation guide for server requirements before you start. [Official Documentation](https://laravel.com/docs/5.4/installation#installation)
Please check the official laravel installation guide for server requirements before you start. [Official Documentation](https://laravel.com/docs/5.6/installation#installation)
Clone the repository
......@@ -49,6 +56,9 @@ Generate a new application key
php artisan key:generate
Generate a new JWT secret key (If you want to use API)
php artisan jwt:secret
Generate a new JWT authentication secret key
php artisan jwt:secret
......@@ -69,10 +79,20 @@ Compile the dependencies
npm run development
For generating the files of unisharp file manager
php artisan vendor:publish --tag=lfm_public
For linking storage folder in public
php artisan storage:link
Start the local development server
php artisan serve
You can now access the server at http://localhost:8000
**TL;DR command list**
......@@ -83,8 +103,10 @@ You can now access the server at http://localhost:8000
composer install
npm install
npm run development
php artisan storage:link
php artisan key:generate
php artisan jwt:generate
php artisan jwt:secret
php artisan vendor:publish --tag=lfm_public
## Logging In
......@@ -112,7 +134,7 @@ Password: `1234`
If you come across any issues please report them [here](https://github.com/viralsolani/laravel-adminpanel/issues).
## 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
......
<?php
namespace App\Events\Backend\EmailTemplates;
use Illuminate\Queue\SerializesModels;
/**
* Class EmailTemplateDeleted.
*/
class EmailTemplateDeleted
{
use SerializesModels;
/**
* @var
*/
public $emailtemplates;
/**
* @param $emailtemplates
*/
public function __construct($emailtemplates)
{
$this->emailtemplates = $emailtemplates;
}
}
<?php
namespace App\Events\Backend\EmailTemplates;
use Illuminate\Queue\SerializesModels;
/**
* Class EmailTemplateUpdated.
*/
class EmailTemplateUpdated
{
use SerializesModels;
/**
* @var
*/
public $emailtemplates;
/**
* @param $emailtemplates
*/
public function __construct($emailtemplates)
{
$this->emailtemplates = $emailtemplates;
}
}
......@@ -9,4 +9,29 @@ use Exception;
*/
class GeneralException extends Exception
{
/**
* message.
*
* @var string
*/
public $message;
/**
* dontHide.
*
* @var bool
*/
public $dontHide;
/**
* Constructor function.
*
* @param string $message
* @param bool $dontHide
*/
public function __construct($message, $dontHide = false)
{
$this->message = $message;
$this->dontHide = $dontHide;
}
}
......@@ -3,9 +3,15 @@
namespace App\Exceptions;
use Exception;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
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
{
......@@ -47,6 +53,52 @@ class Handler extends ExceptionHandler
*/
public function render($request, Exception $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
* Usually because user stayed on the same screen too long and their session expired
......@@ -59,6 +111,8 @@ class Handler extends ExceptionHandler
* All instances of GeneralException redirect back with a flash message to show a bootstrap alert-error
*/
if ($exception instanceof GeneralException) {
session()->flash('dontHide', $exception->dontHide);
return redirect()->back()->withInput()->withFlashDanger($exception->getMessage());
}
......@@ -81,4 +135,58 @@ class Handler extends ExceptionHandler
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);
}
}
<?php
namespace App\Helpers\Macros;
use App\Helpers\Macros\Traits\Dropdowns;
use Collective\Html\FormBuilder;
/**
* Class Macros.
*/
class Macros extends FormBuilder
{
use Dropdowns;
}
This diff is collapsed.
<?php
use App\Exceptions\GeneralException;
use App\Helpers\uuid;
use App\Http\Utilities\SendEmail;
use App\Models\Notification\Notification;
use App\Models\Settings\Setting;
use Carbon\Carbon as Carbon;
......@@ -145,38 +143,25 @@ if (!function_exists('settings')) {
}
}
// Creating Notification
if (!function_exists('createNotification')) {
/**
* create new notification.
*
* @param $message message you want to show in notification
* @param $userId To Whom You Want To send Notification
* @param $type type of notification (1 - dashboard, 2 - email, 3 - both) (by default 1)
* @param $option associate array [ 'data' => $data, 'email_template_type' => $template_type ]
*
* @return object
*/
function createNotification($message, $userId, $type = 1, $options = [])
function createNotification($message, $userId)
{
if ($type == 1 || $type == 3) {
$notification = new Notification();
$notification = new Notification();
return $notification->insert([
'message' => $message,
'user_id' => $userId,
'type' => $type,
'created_at' => Carbon::now(),
]);
}
if ($type == 2 || $type == 3) {
if (!empty($options['data']) && !empty($options['email_template_type'])) {
$mail = new SendEmail();
$emailResult = $mail->sendWithTemplate($options['data'], $options['email_template_type']);
} else {
throw new GeneralException('Invalid input given.option array shold contains data and email_template_type');
}
}
return $notification->insert([
'message' => $message,
'user_id' => $userId,
'type' => 1,
'created_at' => Carbon::now(),
]);
}
}
......
<?php
/**
* Represents a universally unique identifier (UUID), according to RFC 4122.
*
* This class provides the static methods `uuid3()`, `uuid4()`, and
* `uuid5()` for generating version 3, 4, and 5 UUIDs as specified in RFC 4122.
*
* If all you want is a unique ID, you should call `uuid4()`.
*
* @link http://tools.ietf.org/html/rfc4122
* @link http://en.wikipedia.org/wiki/Universally_unique_identifier
* @link http://www.php.net/manual/en/function.uniqid.php#94959
*/
namespace App\Helpers;
class uuid
{
/**
* When this namespace is specified, the name string is a fully-qualified domain name.
*
* @link http://tools.ietf.org/html/rfc4122#appendix-C
*/
const NAMESPACE_DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
/**
* When this namespace is specified, the name string is a URL.
*
* @link http://tools.ietf.org/html/rfc4122#appendix-C
*/
const NAMESPACE_URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
/**
* When this namespace is specified, the name string is an ISO OID.
*
* @link http://tools.ietf.org/html/rfc4122#appendix-C
*/
const NAMESPACE_OID = '6ba7b812-9dad-11d1-80b4-00c04fd430c8';
/**
* When this namespace is specified, the name string is an X.500 DN in DER or a text output format.
*
* @link http://tools.ietf.org/html/rfc4122#appendix-C
*/
const NAMESPACE_X500 = '6ba7b814-9dad-11d1-80b4-00c04fd430c8';
/**
* The nil UUID is special form of UUID that is specified to have all 128 bits set to zero.
*
* @link http://tools.ietf.org/html/rfc4122#section-4.1.7
*/
const NIL = '00000000-0000-0000-0000-000000000000';
private static function getBytes($uuid)
{
if (!self::isValid($uuid)) {
throw new InvalidArgumentException('Invalid UUID string: '.$uuid);
}
// Get hexadecimal components of UUID
$uhex = str_replace([
'urn:',
'uuid:',
'-',
'{',
'}',
], '', $uuid);
// Binary Value
$ustr = '';
// Convert UUID to bits
for ($i = 0; $i < strlen($uhex); $i += 2) {
$ustr .= chr(hexdec($uhex[$i].$uhex[$i + 1]));
}
return $ustr;
}
private static function uuidFromHash($hash, $version)
{
return sprintf('%08s-%04s-%04x-%04x-%12s',
// 32 bits for "time_low"
substr($hash, 0, 8),
// 16 bits for "time_mid"
substr($hash, 8, 4),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number
(hexdec(substr($hash, 12, 4)) & 0x0fff) | $version << 12,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
// 48 bits for "node"
substr($hash, 20, 12));
}
/**
* Generate a version 3 UUID based on the MD5 hash of a namespace identifier
* (which is a UUID) and a name (which is a string).
*
* @param string $namespace The UUID namespace in which to create the named UUID
* @param string $name The name to create a UUID for
*
* @return string
*/
public static function uuid3($namespace, $name)
{
$nbytes = self::getBytes($namespace);
// Calculate hash value
$hash = md5($nbytes.$name);
return self::uuidFromHash($hash, 3);
}
/**
* Generate a version 4 (random) UUID.
*
* @return string
*/
public static function uuid4()
{
$bytes = function_exists('random_bytes') ? random_bytes(16) : openssl_random_pseudo_bytes(16);
$hash = bin2hex($bytes);
return self::uuidFromHash($hash, 4);
}
/**
* Generate a version 5 UUID based on the SHA-1 hash of a namespace
* identifier (which is a UUID) and a name (which is a string).
*
* @param string $namespace The UUID namespace in which to create the named UUID
* @param string $name The name to create a UUID for
*
* @return string
*/
public static function uuid5($namespace, $name)
{
$nbytes = self::getBytes($namespace);
// Calculate hash value
$hash = sha1($nbytes.$name);
return self::uuidFromHash($hash, 5);
}
/**
* Check if a string is a valid UUID.
*
* @param string $uuid The string UUID to test
*
* @return bool
*/
public static function isValid($uuid)
{
return preg_match('/^(urn:)?(uuid:)?(\{)?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?[0-9a-f]{12}(?(3)\}|)$/i', $uuid) === 1;
}
/**
* Check if two UUIDs are equal.
*
* @param string $uuid1 The first UUID to test
* @param string $uuid2 The second UUID to test
*
* @return bool
*/
public static function equals($uuid1, $uuid2)
{
return self::getBytes($uuid1) === self::getBytes($uuid2);
}
}
......@@ -9,7 +9,6 @@ require __DIR__.'/Access/User.php';
require __DIR__.'/Access/Role.php';
require __DIR__.'/Access/Permission.php';
require __DIR__.'/Page.php';
require __DIR__.'/Email_Template.php';
require __DIR__.'/Setting.php';
require __DIR__.'/Blog_Category.php';
require __DIR__.'/Blog_Tag.php';
......
<?php
Breadcrumbs::register('admin.blogcategories.index', function ($breadcrumbs) {
Breadcrumbs::register('admin.blogCategories.index', function ($breadcrumbs) {
$breadcrumbs->parent('admin.dashboard');
$breadcrumbs->push(trans('menus.backend.blogcategories.management'), route('admin.blogcategories.index'));
$breadcrumbs->push(trans('menus.backend.blogcategories.management'), route('admin.blogCategories.index'));
});
Breadcrumbs::register('admin.blogcategories.create', function ($breadcrumbs) {
$breadcrumbs->parent('admin.blogcategories.index');
$breadcrumbs->push(trans('menus.backend.blogcategories.create'), route('admin.blogcategories.create'));
Breadcrumbs::register('admin.blogCategories.create', function ($breadcrumbs) {
$breadcrumbs->parent('admin.blogCategories.index');
$breadcrumbs->push(trans('menus.backend.blogcategories.create'), route('admin.blogCategories.create'));
});
Breadcrumbs::register('admin.blogcategories.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.blogcategories.index');
$breadcrumbs->push(trans('menus.backend.blogcategories.edit'), route('admin.blogcategories.edit', $id));
Breadcrumbs::register('admin.blogCategories.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.blogCategories.index');
$breadcrumbs->push(trans('menus.backend.blogcategories.edit'), route('admin.blogCategories.edit', $id));
});
<?php
Breadcrumbs::register('admin.blogtags.index', function ($breadcrumbs) {
Breadcrumbs::register('admin.blogTags.index', function ($breadcrumbs) {
$breadcrumbs->parent('admin.dashboard');
$breadcrumbs->push(trans('menus.backend.blogtags.management'), route('admin.blogtags.index'));
$breadcrumbs->push(trans('menus.backend.blogtags.management'), route('admin.blogTags.index'));
});
Breadcrumbs::register('admin.blogtags.create', function ($breadcrumbs) {
$breadcrumbs->parent('admin.blogtags.index');
$breadcrumbs->push(trans('menus.backend.blogtags.create'), route('admin.blogtags.create'));
Breadcrumbs::register('admin.blogTags.create', function ($breadcrumbs) {
$breadcrumbs->parent('admin.blogTags.index');
$breadcrumbs->push(trans('menus.backend.blogtags.create'), route('admin.blogTags.create'));
});
Breadcrumbs::register('admin.blogtags.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.blogtags.index');
$breadcrumbs->push(trans('menus.backend.blogtags.edit'), route('admin.blogtags.edit', $id));
Breadcrumbs::register('admin.blogTags.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.blogTags.index');
$breadcrumbs->push(trans('menus.backend.blogtags.edit'), route('admin.blogTags.edit', $id));
});
<?php
Breadcrumbs::register('admin.emailtemplates.index', function ($breadcrumbs) {
$breadcrumbs->parent('admin.dashboard');
$breadcrumbs->push(trans('menus.backend.emailtemplates.management'), route('admin.emailtemplates.index'));
});
Breadcrumbs::register('admin.emailtemplates.create', function ($breadcrumbs) {
$breadcrumbs->parent('admin.emailtemplates.index');
$breadcrumbs->push(trans('menus.backend.emailtemplates.create'), route('admin.emailtemplates.create'));
});
Breadcrumbs::register('admin.emailtemplates.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.emailtemplates.index');
$breadcrumbs->push(trans('menus.backend.emailtemplates.edit'), route('admin.emailtemplates.edit', $id));
});
......@@ -178,7 +178,7 @@ class APIController extends Controller
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.
*
* @param string $message
......@@ -188,6 +188,6 @@ class APIController extends Controller
public function throwValidation($message)
{
return $this->setStatusCode(422)
->respondWithError($message);
->respondWithError($message);
}
}
......@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api\V1;
use App\Models\Access\User\User;
use Illuminate\Http\Request;
use JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException;
......
<?php
namespace App\Http\Controllers\Api\V1;
use App\Http\Resources\BlogCategoriesResource;
use App\Models\BlogCategories\BlogCategory;
use App\Repositories\Backend\BlogCategories\BlogCategoriesRepository;
use Illuminate\Http\Request;
use Validator;
class BlogCategoriesController extends APIController
{
protected $repository;
/**
* __construct.
*
* @param $repository
*/
public function __construct(BlogCategoriesRepository $repository)
{
$this->repository = $repository;
}
/**
* Return the blog-categories.
*
* @param Request $request
*
*@return \Illuminate\Http\JsonResponse
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return BlogCategoriesResource::collection(
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
/**
* Return the specified resource.
*
* @param BlogCategory $blog_category
*
*@return \Illuminate\Http\JsonResponse
*/
public function show(BlogCategory $blog_category)
{
return new BlogCategoriesResource($blog_category);
}
/**
* Creates the Resource for BlogCategory.
*
* @param Request $request
*
*@return \Illuminate\Http\JsonResponse
*/
public function store(Request $request)
{
$validation = $this->validateBlogCategory($request);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$this->repository->create($request->all());
return new BlogCategoriesResource(BlogCategory::orderBy('created_at', 'desc')->first());
}
/**
* @param BlogCategory $blog_category
* @param Request $request
*
* @return mixed
*/
public function update(Request $request, BlogCategory $blog_category)
{
$validation = $this->validateBlogCategory($request);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$this->repository->update($blog_category, $request->all());
$blog_category = BlogCategory::findOrfail($blog_category->id);
return new BlogCategoriesResource($blog_category);
}
/**
* @param BlogCategory $blog_category
* @param Request $request
*
* @return mixed
*/
public function destroy(BlogCategory $blog_category, Request $request)
{
$this->repository->delete($blog_category);
return $this->respond([
'message' => trans('alerts.backend.blogcategories.deleted'),
]);
}
/**
* validateUser BlogCategory Requests.
*
* @param Request $request
*
* @return Validator object
*/
public function validateBlogCategory(Request $request)
{
$validation = Validator::make($request->all(), [
'name' => 'required|max:191',
]);
return $validation;
}
}
<?php
namespace App\Http\Controllers\Api\V1;
use App\Http\Resources\BlogTagsResource;
use App\Models\BlogTags\BlogTag;
use App\Repositories\Backend\BlogTags\BlogTagsRepository;
use Illuminate\Http\Request;
use Validator;
class BlogTagsController extends APIController
{
protected $repository;
/**
* __construct.
*
* @param $repository
*/
public function __construct(BlogTagsRepository $repository)
{
$this->repository = $repository;
}
/**
* Return the BlogTags.
*
* @return \Illuminate\Http\JsonResponse
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return BlogTagsResource::collection(
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
/**
* Return the specified resource.
*
* @param BlogTag $blog_tag
*
* @return \Illuminate\Http\JsonResponse
*/
public function show(BlogTag $blog_tag)
{
return new BlogTagsResource($blog_tag);
}
/**
* Creates the Resource for BlogTag.
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function store(Request $request)
{
$validation = $this->validatingRequest($request);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$this->repository->create($request->all());
return new BlogTagsResource(BlogTag::orderBy('created_at', 'desc')->first());
}
/**
* Update BlogTag.
*
* @param BlogTag $blog_tag
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function update(Request $request, BlogTag $blog_tag)
{
$validation = $this->validatingRequest($request, $blog_tag->id);
if ($validation->fails()) {
return $this->throwValidation($validation);
}
$this->repository->update($blog_tag, $request->all());
$blog_tag = BlogTag::findOrfail($blog_tag->id);
return new BlogTagsResource($blog_tag);
}
/**
* Delete BlogTag.
*
* @param BlogTag $blog_tag
* @param DeleteBlogTagRequest $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function destroy(BlogTag $blog_tag, Request $request)
{
$this->repository->delete($blog_tag);
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;
}
}
<?php
namespace App\Http\Controllers\Api\V1;
use App\Http\Resources\BlogsResource;
use App\Models\Blogs\Blog;
use App\Repositories\Backend\Blogs\BlogsRepository;
use Illuminate\Http\Request;
use Validator;
class BlogsController extends APIController
{
protected $repository;
/**
* __construct.
*
* @param $repository
*/
public function __construct(BlogsRepository $repository)
{
$this->repository = $repository;
}
/**
* Return the blogs.
*
* @return \Illuminate\Http\JsonResponse
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return BlogsResource::collection(
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
/**
* Return the specified resource.
*
* @param Blog blog
*
* @return \Illuminate\Http\JsonResponse
*/
public function show(Blog $blog)
{
return new BlogsResource($blog);
}
/**
* Creates the Resource for Blog.
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function store(Request $request)
{
$validation = $this->validateBlog($request);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$this->repository->create($request->all());
return new BlogsResource(Blog::orderBy('created_at', 'desc')->first());
}
/**
* Update blog.
*
* @param Blog $blog
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function update(Request $request, Blog $blog)
{
$validation = $this->validateBlog($request, 'update');
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$this->repository->update($blog, $request->all());
$blog = Blog::findOrfail($blog->id);
return new BlogsResource($blog);
}
/**
* Delete Blog.
*
* @param Blog $blog
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function destroy(Blog $blog, Request $request)
{
$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' : '';
$publish_datetime = $request->publish_datetime !== '' ? 'required|date' : 'required';
$validation = Validator::make($request->all(), [
'name' => 'required|max:191',
'featured_image' => $featured_image,
'publish_datetime' => $publish_datetime,
'content' => 'required',
'categories' => 'required',
'tags' => 'required',
]);
return $validation;
}
/**
* validate message for validate blog.
*
* @return \Illuminate\Http\JsonResponse
*/
public function messages()
{
return [
'name.required' => 'Please insert Blog Title',
'name.max' => 'Blog Title may not be greater than 191 characters.',
];
}
}
<?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;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return UserResource::collection(
$this->repository->getForDataTable(0, false)->orderBy($sortBy, $orderBy)->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;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return UserResource::collection(
$this->repository->getForDataTable(0, true)->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
}
<?php
namespace App\Http\Controllers\Api\V1;
use App\Http\Resources\FaqsResource;
use App\Models\Faqs\Faq;
use App\Repositories\Backend\Faqs\FaqsRepository;
use Illuminate\Http\Request;
use Validator;
class FaqsController extends APIController
{
protected $repository;
/**
* __construct.
*
* @param $repository
*/
public function __construct(FaqsRepository $repository)
{
$this->repository = $repository;
}
/**
* Return the faqs.
*
* @return \Illuminate\Http\JsonResponse
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return FaqsResource::collection(
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
/**
* Return the specified resource.
*
* @param Faq $faq
*
* @return \Illuminate\Http\JsonResponse
*/
public function show(Faq $faq)
{
return new FaqsResource($faq);
}
/**
* Creates the Resource for Faq.
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function store(Request $request)
{
$validation = $this->validateFaq($request);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$this->repository->create($request->all());
return new FaqsResource(Faq::orderBy('created_at', 'desc')->first());
}
/**
* Update Faq.
*
* @param Faq $faq
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function update(Request $request, Faq $faq)
{
$validation = $this->validateFaq($request);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$this->repository->update($faq, $request->all());
$faq = Faq::findOrfail($faq->id);
return new FaqsResource($faq);
}
/**
* Delete Faq.
*
* @param Faq $faq
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function destroy(Faq $faq, Request $request)
{
$this->repository->delete($faq);
return $this->respond([
'message' => trans('alerts.backend.faqs.deleted'),
]);
}
/**
* validate Faq.
*
* @param $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function validateFaq(Request $request)
{
$validation = Validator::make($request->all(), [
'question' => 'required|max:191',
'answer' => 'required',
]);
return $validation;
}
}
<?php
namespace App\Http\Controllers\Api\V1;
use App\Http\Resources\PagesResource;
use App\Models\Page\Page;
use App\Repositories\Backend\Pages\PagesRepository;
use Illuminate\Http\Request;
use Validator;
class PagesController extends APIController
{
protected $repository;
/**
* __construct.
*
* @param $repository
*/
public function __construct(PagesRepository $repository)
{
$this->repository = $repository;
}
/**
* Return the pages.
*
* @return \Illuminate\Http\JsonResponse
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : config('module.pages.table', 'pages').'created_at';
return PagesResource::collection(
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
/**
* Return the specified resource.
*
* @param Pages $page
*
* @return \Illuminate\Http\JsonResponse
*/
public function show(Page $page)
{
return new PagesResource($page);
}
/**
* Creates the Resource for Page.
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function store(Request $request)
{
$validation = $this->validatePages($request);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$page = $this->repository->create($request->all());
return new PagesResource($page);
}
/**
* Update Page.
*
* @param Page $page
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function update(Request $request, Page $page)
{
$validation = $this->validatePages($request, $page->id);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$this->repository->update($page, $request->all());
$page = Page::findOrfail($page->id);
return new PagesResource($page);
}
/**
* Delete Page.
*
* @param Page $page
* @param DeletePageRequest $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function destroy(Page $page, Request $request)
{
$this->repository->delete($page);
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;
}
}
<?php
namespace App\Http\Controllers\Api\V1;
use App\Http\Resources\PermissionResource;
use App\Models\Access\Permission\Permission;
use App\Repositories\Backend\Access\Permission\PermissionRepository;
use Illuminate\Http\Request;
use Validator;
class PermissionController extends APIController
{
protected $repository;
/**
* __construct.
*
* @param $repository
*/
public function __construct(PermissionRepository $repository)
{
$this->repository = $repository;
}
/**
* Return the permissions.
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return PermissionResource::collection(
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
/**
* Return the specified resource.
*
* @param Permission $permission
*
* @return \Illuminate\Http\JsonResponse
*/
public function show(Permission $permission)
{
return new PermissionResource($permission);
}
/**
* Creates the Resource for Permission.
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function store(Request $request)
{
$validation = $this->validatePermission($request);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$this->repository->create($request->all());
$permission = Permission::orderBy('created_at', 'desc')->first();
return new PermissionResource($permission);
}
/**
* @param Permission $permission
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function update(Request $request, Permission $permission)
{
$validation = $this->validatePermission($request, $permission->id);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$this->repository->update($permission, $request->all());
$permission = Permission::findOrfail($permission->id);
return new PermissionResource($permission);
}
/**
* Delete permission.
*
* @param Role $role
* @param DeleteRoleRequest $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function destroy(Permission $permission, Request $request)
{
$this->repository->delete($permission);
return $this->respond([
'data' => $permission->id,
'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;
}
}
<?php
namespace App\Http\Controllers\Api\V1;
use App\Http\Resources\RoleResource;
use App\Models\Access\Role\Role;
use App\Repositories\Backend\Access\Role\RoleRepository;
use Illuminate\Http\Request;
use Validator;
class RolesController extends APIController
{
protected $repository;
/**
* __construct.
*
* @param $repository
*/
public function __construct(RoleRepository $repository)
{
$this->repository = $repository;
}
/**
* Return the roles.
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return RoleResource::collection(
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
/**
* Return the specified resource.
*
* @param Role $role
*
* @return \Illuminate\Http\JsonResponse
*/
public function show(Role $role)
{
return new RoleResource($role);
}
/**
* Creates the Resource for Role.
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function store(Request $request)
{
$validation = $this->validateRole($request);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$this->repository->create($request->all());
return new RoleResource(Role::orderBy('created_at', 'desc')->first());
}
/**
* Update Role.
*
* @param Request $request
* @param Role $role
*
* @return \Illuminate\Http\JsonResponse
*/
public function update(Request $request, Role $role)
{
$validation = $this->validateRole($request, $role->id);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$this->repository->update($role, $request->all());
$role = Role::findOrfail($role->id);
return new RoleResource($role);
}
/**
* 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([
'data' => $role->id,
'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 = '';
if ($request->post('associated_permissions') != 'all') {
$permissions = 'required';
}
$validation = Validator::make($request->all(), [
'name' => 'required|max:191|unique:roles,name,'.$id,
'permissions' => $permissions,
]);
return $validation;
}
}
......@@ -3,7 +3,7 @@
namespace App\Http\Controllers\Api\V1;
use App\Http\Resources\UserResource;
use App\Models\User\User;
use App\Models\Access\User\User;
use App\Repositories\Backend\Access\User\UserRepository;
use Illuminate\Http\Request;
use Validator;
......@@ -25,14 +25,18 @@ class UsersController extends APIController
/**
* Return the users.
*
* @return \Illuminate\Http\Response
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
return UserResource::collection(
$this->repository->getPaginated($limit)
$this->repository->getForDataTable(1, false)->orderBy($sortBy, $orderBy)->paginate($limit)
);
}
......@@ -41,7 +45,7 @@ class UsersController extends APIController
*
* @param User $user
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\JsonResponse
*/
public function show(User $user)
{
......@@ -49,22 +53,114 @@ class UsersController extends APIController
}
/**
* Update the specified resource in storage.
* Create User.
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function store(Request $request)
{
$validation = $this->validateUser($request);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$this->repository->create($request);
return new UserResource(User::orderBy('created_at', 'desc')->first());
}
/**
* Update User.
*
* @param Request $request
* @param User $user
*
* @return Validator object
*/
public function update(Request $request, User $user)
{
$validation = Validator::make($request->all(), [
'name' => 'required',
'email' => 'email|unique:users,email,'.$user->id,
'password' => 'nullable|confirmed',
]);
$validation = $this->validateUser($request, 'edit', $user->id);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
$user = $this->repository->update($user->id, $request->all());
$this->repository->update($user, $request);
$user = User::findOrfail($user->id);
return new UserResource($user);
}
/**
* Delete User.
*
* @param User $user
* @param Request $request
*
* @return mixed
*/
public function destroy(User $user, Request $request)
{
$this->repository->delete($user);
return $this->respond([
'data' => $user->id,
'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);
}
if ($result) {
return $this->respond([
'message' => trans('alerts.backend.users.deleted'),
]);
}
return $this->respond([
'message' => trans('exceptions.backend.access.users.not_found'),
]);
}
/**
* validateUser User.
*
* @param $request
* @param $action
* @param $id
*
* @return \Illuminate\Http\JsonResponse
*/
public function validateUser(Request $request, $action = '', $id = 0)
{
$password = ($action == 'edit') ? '' : 'required|min:6|confirmed';
$validation = Validator::make($request->all(), [
'first_name' => 'required|max:255',
'last_name' => 'required|max:255',
'email' => 'required|max:255|email|unique:users,email,'.$id,
'password' => $password,
'assignees_roles' => 'required',
'permissions' => 'required',
]);
return $validation;
}
}
......@@ -9,6 +9,10 @@ use App\Http\Requests\Backend\Access\Permission\EditPermissionRequest;
use App\Http\Requests\Backend\Access\Permission\ManagePermissionRequest;
use App\Http\Requests\Backend\Access\Permission\StorePermissionRequest;
use App\Http\Requests\Backend\Access\Permission\UpdatePermissionRequest;
use App\Http\Responses\Backend\Access\Permission\CreateResponse;
use App\Http\Responses\Backend\Access\Permission\EditResponse;
use App\Http\Responses\RedirectResponse;
use App\Http\Responses\ViewResponse;
use App\Models\Access\Permission\Permission;
use App\Repositories\Backend\Access\Permission\PermissionRepository;
......@@ -33,71 +37,69 @@ class PermissionController extends Controller
/**
* @param ManagePermissionRequest $request
*
* @return mixed
* @return \App\Http\Responses\ViewResponse
*/
public function index(ManagePermissionRequest $request)
{
return view('backend.access.permissions.index');
return new ViewResponse('backend.access.permissions.index');
}
/**
* @param CreatePermissionRequest $request
*
* @return mixed
* @return \App\Http\Responses\Backend\Access\Permission\CreateResponse
*/
public function create(CreatePermissionRequest $request)
{
return view('backend.access.permissions.create')
->withPermissionCount($this->permissions->getCount());
return new CreateResponse($this->permissions);
}
/**
* @param StorePermissionRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function store(StorePermissionRequest $request)
{
$this->permissions->create($request->all());
return redirect()->route('admin.access.permission.index')->withFlashSuccess(trans('alerts.backend.permissions.created'));
return new RedirectResponse(route('admin.access.permission.index'), ['flash_success' => trans('alerts.backend.permissions.created')]);
}
/**
* @param Permission $permission
* @param EditPermissionRequest $request
*
* @return mixed
* @return \App\Http\Responses\Backend\Access\Permission\EditResponse
*/
public function edit(Permission $permission, EditPermissionRequest $request)
{
return view('backend.access.permissions.edit')
->withPermission($permission);
return new EditResponse($permission);
}
/**
* @param Permission $permission
* @param UpdatePermissionRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function update(Permission $permission, UpdatePermissionRequest $request)
{
$this->permissions->update($permission, $request->all());
return redirect()->route('admin.access.permission.index')->withFlashSuccess(trans('alerts.backend.permissions.updated'));
return new RedirectResponse(route('admin.access.permission.index'), ['flash_success' => trans('alerts.backend.permissions.updated')]);
}
/**
* @param Permission $permission
* @param DeletePermissionRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function destroy(Permission $permission, DeletePermissionRequest $request)
{
$this->permissions->delete($permission);
return redirect()->route('admin.access.permission.index')->withFlashSuccess(trans('alerts.backend.permissions.deleted'));
return new RedirectResponse(route('admin.access.permission.index'), ['flash_success' => trans('alerts.backend.permissions.deleted')]);
}
}
......@@ -9,6 +9,10 @@ use App\Http\Requests\Backend\Access\Role\EditRoleRequest;
use App\Http\Requests\Backend\Access\Role\ManageRoleRequest;
use App\Http\Requests\Backend\Access\Role\StoreRoleRequest;
use App\Http\Requests\Backend\Access\Role\UpdateRoleRequest;
use App\Http\Responses\Backend\Access\Role\CreateResponse;
use App\Http\Responses\Backend\Access\Role\EditResponse;
use App\Http\Responses\RedirectResponse;
use App\Http\Responses\ViewResponse;
use App\Models\Access\Role\Role;
use App\Repositories\Backend\Access\Permission\PermissionRepository;
use App\Repositories\Backend\Access\Role\RoleRepository;
......@@ -19,18 +23,18 @@ use App\Repositories\Backend\Access\Role\RoleRepository;
class RoleController extends Controller
{
/**
* @var RoleRepository
* @var \App\Repositories\Backend\Access\Role\RoleRepository
*/
protected $roles;
/**
* @var PermissionRepository
* @var \App\Repositories\Backend\Access\Permission\PermissionRepository
*/
protected $permissions;
/**
* @param RoleRepository $roles
* @param PermissionRepository $permissions
* @param \App\Repositories\Backend\Access\Role\RoleRepository $roles
* @param \App\Repositories\Backend\Access\Permission\PermissionRepository $permissions
*/
public function __construct(RoleRepository $roles, PermissionRepository $permissions)
{
......@@ -39,76 +43,71 @@ class RoleController extends Controller
}
/**
* @param ManageRoleRequest $request
* @param \App\Http\Requests\Backend\Access\Role\ManageRoleRequest $request
*
* @return mixed
*/
public function index(ManageRoleRequest $request)
{
return view('backend.access.roles.index');
return new ViewResponse('backend.access.roles.index');
}
/**
* @param CreateRoleRequest $request
* @param \App\Http\Requests\Backend\Access\Role\CreateRoleRequest $request
*
* @return mixed
* @return \App\Http\Responses\Backend\Access\Role\CreateResponse
*/
public function create(CreateRoleRequest $request)
{
return view('backend.access.roles.create')
->withPermissions($this->permissions->getAll())
->withRoleCount($this->roles->getCount());
return new CreateResponse($this->permissions, $this->roles);
}
/**
* @param StoreRoleRequest $request
* @param \App\Http\Requests\Backend\Access\Role\StoreRoleRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function store(StoreRoleRequest $request)
{
$this->roles->create($request->all());
return redirect()->route('admin.access.role.index')->withFlashSuccess(trans('alerts.backend.roles.created'));
return new RedirectResponse(route('admin.access.role.index'), ['flash_success' => trans('alerts.backend.roles.created')]);
}
/**
* @param Role $role
* @param EditRoleRequest $request
* @param \App\Models\Access\Role\Role $role
* @param \App\Http\Requests\Backend\Access\Role\EditRoleRequest $request
*
* @return mixed
* @return \App\Http\Responses\Backend\Access\Role\EditResponse
*/
public function edit(Role $role, EditRoleRequest $request)
{
return view('backend.access.roles.edit')
->withRole($role)
->withRolePermissions($role->permissions->pluck('id')->all())
->withPermissions($this->permissions->getAll());
return new EditResponse($role, $this->permissions);
}
/**
* @param Role $role
* @param UpdateRoleRequest $request
* @param \App\Models\Access\Role\Role $role
* @param \App\Http\Requests\Backend\Access\Role\UpdateRoleRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function update(Role $role, UpdateRoleRequest $request)
{
$this->roles->update($role, $request->all());
return redirect()->route('admin.access.role.index')->withFlashSuccess(trans('alerts.backend.roles.updated'));
return new RedirectResponse(route('admin.access.role.index'), ['flash_success' => trans('alerts.backend.roles.updated')]);
}
/**
* @param Role $role
* @param DeleteRoleRequest $request
* @param \App\Models\Access\Role\Role $role
* @param \App\Http\Requests\Backend\Access\Role\DeleteRoleRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function destroy(Role $role, DeleteRoleRequest $request)
{
$this->roles->delete($role);
return redirect()->route('admin.access.role.index')->withFlashSuccess(trans('alerts.backend.roles.deleted'));
return new RedirectResponse(route('admin.access.role.index'), ['flash_success' => trans('alerts.backend.roles.deleted')]);
}
}
......@@ -10,6 +10,11 @@ use App\Http\Requests\Backend\Access\User\ManageUserRequest;
use App\Http\Requests\Backend\Access\User\ShowUserRequest;
use App\Http\Requests\Backend\Access\User\StoreUserRequest;
use App\Http\Requests\Backend\Access\User\UpdateUserRequest;
use App\Http\Responses\Backend\Access\User\CreateResponse;
use App\Http\Responses\Backend\Access\User\EditResponse;
use App\Http\Responses\Backend\Access\User\ShowResponse;
use App\Http\Responses\RedirectResponse;
use App\Http\Responses\ViewResponse;
use App\Models\Access\Permission\Permission;
use App\Models\Access\User\User;
use App\Repositories\Backend\Access\Role\RoleRepository;
......@@ -21,18 +26,18 @@ use App\Repositories\Backend\Access\User\UserRepository;
class UserController extends Controller
{
/**
* @var UserRepository
* @var \App\Repositories\Backend\Access\User\UserRepository
*/
protected $users;
/**
* @var RoleRepository
* @var \App\Repositories\Backend\Access\Role\RoleRepository
*/
protected $roles;
/**
* @param UserRepository $users
* @param RoleRepository $roles
* @param \App\Repositories\Backend\Access\User\UserRepository $users
* @param \App\Repositories\Backend\Access\Role\RoleRepository $roles
*/
public function __construct(UserRepository $users, RoleRepository $roles)
{
......@@ -41,94 +46,87 @@ class UserController extends Controller
}
/**
* @param ManageUserRequest $request
* @param \App\Http\Requests\Backend\Access\User\ManageUserRequest $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @return \App\Http\Responses\ViewResponse
*/
public function index(ManageUserRequest $request)
{
return view('backend.access.users.index');
return new ViewResponse('backend.access.users.index');
}
/**
* @param CreateUserRequest $request
* @param \App\Http\Requests\Backend\Access\User\CreateUserRequest $request
*
* @return mixed
* @return \App\Http\Responses\Backend\Access\User\CreateResponse
*/
public function create(CreateUserRequest $request)
{
return view('backend.access.users.create')->with([
'roles' => $this->roles->getAll(),
]);
$roles = $this->roles->getAll();
return new CreateResponse($roles);
}
/**
* @param StoreUserRequest $request
* @param \App\Http\Requests\Backend\Access\User\StoreUserRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function store(StoreUserRequest $request)
{
$this->users->create($request);
return redirect()->route('admin.access.user.index')->withFlashSuccess(trans('alerts.backend.users.created'));
return new RedirectResponse(route('admin.access.user.index'), ['flash_success' => trans('alerts.backend.users.created')]);
}
/**
* @param User $user
* @param ShowUserRequest $request
* @param \App\Models\Access\User\User $user
* @param \App\Http\Requests\Backend\Access\User\ShowUserRequest $request
*
* @return mixed
* @return \App\Http\Responses\Backend\Access\User\ShowResponse
*/
public function show(User $user, ShowUserRequest $request)
{
return view('backend.access.users.show')
->withUser($user);
return new ShowResponse($user);
}
/**
* @param User $user
* @param EditUserRequest $request
* @param \App\Models\Access\User\User $user
* @param \App\Http\Requests\Backend\Access\User\EditUserRequest $request
*
* @return mixed
* @return \App\Http\Responses\Backend\Access\User\EditResponse
*/
public function edit(User $user, EditUserRequest $request)
{
$roles = $this->roles->getAll();
$permissions = Permission::getSelectData('display_name');
$userPermissions = $user->permissions()->get()->pluck('id')->toArray();
return view('backend.access.users.edit')->with([
'user' => $user,
'userRoles' => $user->roles->pluck('id')->all(),
'roles' => $this->roles->getAll(),
'userPermissions' => $userPermissions,
'permissions' => $permissions,
]);
return new EditResponse($user, $roles, $permissions);
}
/**
* @param User $user
* @param UpdateUserRequest $request
* @param \App\Models\Access\User\User $user
* @param \App\Http\Requests\Backend\Access\User\UpdateUserRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function update(User $user, UpdateUserRequest $request)
{
$this->users->update($user, $request);
return redirect()->route('admin.access.user.index')->withFlashSuccess(trans('alerts.backend.users.updated'));
return new RedirectResponse(route('admin.access.user.index'), ['flash_success' => trans('alerts.backend.users.updated')]);
}
/**
* @param User $user
* @param DeleteUserRequest $request
* @param \App\Models\Access\User\User $user
* @param \App\Http\Requests\Backend\Access\User\DeleteUserRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function destroy(User $user, DeleteUserRequest $request)
{
$this->users->delete($user);
return redirect()->route('admin.access.user.deleted')->withFlashSuccess(trans('alerts.backend.users.deleted'));
return new RedirectResponse(route('admin.access.user.index'), ['flash_success' => trans('alerts.backend.users.deleted')]);
}
}
......@@ -14,12 +14,12 @@ use Yajra\DataTables\Facades\DataTables;
class UserTableController extends Controller
{
/**
* @var UserRepository
* @var \App\Repositories\Backend\Access\User\UserRepository
*/
protected $users;
/**
* @param UserRepository $users
* @param \App\Repositories\Backend\Access\User\UserRepository $users
*/
public function __construct(UserRepository $users)
{
......@@ -27,7 +27,7 @@ class UserTableController extends Controller
}
/**
* @param ManageUserRequest $request
* @param \App\Http\Requests\Backend\Access\User\ManageUserRequest $request
*
* @return mixed
*/
......
......@@ -9,6 +9,9 @@ use App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\ManageBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\StoreBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\UpdateBlogCategoriesRequest;
use App\Http\Responses\Backend\BlogCategory\EditResponse;
use App\Http\Responses\RedirectResponse;
use App\Http\Responses\ViewResponse;
use App\Models\BlogCategories\BlogCategory;
use App\Repositories\Backend\BlogCategories\BlogCategoriesRepository;
......@@ -30,21 +33,21 @@ class BlogCategoriesController extends Controller
/**
* @param \App\Http\Requests\Backend\BlogCategories\ManageBlogCategoriesRequest $request
*
* @return mixed
* @return ViewResponse
*/
public function index(ManageBlogCategoriesRequest $request)
{
return view('backend.blogcategories.index');
return new ViewResponse('backend.blogcategories.index');
}
/**
* @param \App\Http\Requests\Backend\BlogCategories\CreateBlogCategoriesRequest $request
*
* @return mixed
* @return \App\Http\Responses\ViewResponse
*/
public function create(CreateBlogCategoriesRequest $request)
{
return view('backend.blogcategories.create');
return new ViewResponse('backend.blogcategories.create');
}
/**
......@@ -56,50 +59,43 @@ class BlogCategoriesController extends Controller
{
$this->blogcategory->create($request->all());
return redirect()
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.created'));
return new RedirectResponse(route('admin.blogCategories.index'), ['flash_success' => trans('alerts.backend.blogcategories.created')]);
}
/**
* @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param \App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest $request
*
* @return mixed
* @return \App\Http\Responses\Backend\BlogCategory\EditResponse
*/
public function edit(BlogCategory $blogCategory, EditBlogCategoriesRequest $request)
{
return view('backend.blogcategories.edit')
->with('blogcategory', $blogCategory);
return new EditResponse($blogCategory);
}
/**
* @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param \App\Http\Requests\Backend\BlogCategories\UpdateBlogCategoriesRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function update(BlogCategory $blogCategory, UpdateBlogCategoriesRequest $request)
{
$this->blogcategory->update($blogCategory, $request->all());
return redirect()
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.updated'));
return new RedirectResponse(route('admin.blogCategories.index'), ['flash_success' => trans('alerts.backend.blogcategories.updated')]);
}
/**
* @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param \App\Http\Requests\Backend\BlogCategories\DeleteBlogCategoriesRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function destroy(BlogCategory $blogCategory, DeleteBlogCategoriesRequest $request)
{
$this->blogcategory->delete($blogCategory);
return redirect()
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.deleted'));
return new RedirectResponse(route('admin.blogCategories.index'), ['flash_success' => trans('alerts.backend.blogcategories.deleted')]);
}
}
......@@ -9,6 +9,9 @@ use App\Http\Requests\Backend\BlogTags\EditBlogTagsRequest;
use App\Http\Requests\Backend\BlogTags\ManageBlogTagsRequest;
use App\Http\Requests\Backend\BlogTags\StoreBlogTagsRequest;
use App\Http\Requests\Backend\BlogTags\UpdateBlogTagsRequest;
use App\Http\Responses\Backend\BlogTag\EditResponse;
use App\Http\Responses\RedirectResponse;
use App\Http\Responses\ViewResponse;
use App\Models\BlogTags\BlogTag;
use App\Repositories\Backend\BlogTags\BlogTagsRepository;
......@@ -33,47 +36,44 @@ class BlogTagsController extends Controller
/**
* @param \App\Http\Requests\Backend\BlogTags\ManageBlogTagsRequest $request
*
* @return mixed
* @return \App\Http\Responses\ViewResponse
*/
public function index(ManageBlogTagsRequest $request)
{
return view('backend.blogtags.index');
return new ViewResponse('backend.blogtags.index');
}
/**
* @param \App\Http\Requests\Backend\BlogTags\CreateBlogTagsRequest $request
*
* @return mixed
* @return \App\Http\Responses\ViewResponse
*/
public function create(CreateBlogTagsRequest $request)
{
return view('backend.blogtags.create');
return new ViewResponse('backend.blogtags.create');
}
/**
* @param \App\Http\Requests\Backend\BlogTags\StoreBlogTagsRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function store(StoreBlogTagsRequest $request)
{
$this->blogtag->create($request->except('token'));
return redirect()
->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.created'));
return new RedirectResponse(route('admin.blogTags.index'), ['flash_success' => trans('alerts.backend.blogtags.created')]);
}
/**
* @param \App\Models\BlogTags\BlogTag $blogTag
* @param \App\Http\Requests\Backend\BlogTags\EditBlogTagsRequest $request
*
* @return mixed
* @return \App\Http\Responses\Backend\BlogTag\EditResponse
*/
public function edit(BlogTag $blogTag, EditBlogTagsRequest $request)
{
return view('backend.blogtags.edit')
->with('blogtag', $blogTag);
return new EditResponse($blogTag);
}
/**
......@@ -86,9 +86,7 @@ class BlogTagsController extends Controller
{
$this->blogtag->update($blogTag, $request->except(['_method', '_token']));
return redirect()
->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.updated'));
return new RedirectResponse(route('admin.blogTags.index'), ['flash_success' => trans('alerts.backend.blogtags.updated')]);
}
/**
......@@ -101,8 +99,6 @@ class BlogTagsController extends Controller
{
$this->blogtag->delete($blogTag);
return redirect()
->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.deleted'));
return new RedirectResponse(route('admin.blogTags.index'), ['flash_success' => trans('alerts.backend.blogtags.deleted')]);
}
}
......@@ -6,6 +6,10 @@ use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Blogs\ManageBlogsRequest;
use App\Http\Requests\Backend\Blogs\StoreBlogsRequest;
use App\Http\Requests\Backend\Blogs\UpdateBlogsRequest;
use App\Http\Responses\Backend\Blog\CreateResponse;
use App\Http\Responses\Backend\Blog\EditResponse;
use App\Http\Responses\Backend\Blog\IndexResponse;
use App\Http\Responses\RedirectResponse;
use App\Models\BlogCategories\BlogCategory;
use App\Models\Blogs\Blog;
use App\Models\BlogTags\BlogTag;
......@@ -42,13 +46,11 @@ class BlogsController extends Controller
/**
* @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request
*
* @return mixed
* @return \App\Http\Responses\Backend\Blog\IndexResponse
*/
public function index(ManageBlogsRequest $request)
{
return view('backend.blogs.index')->with([
'status'=> $this->status,
]);
return new IndexResponse($this->status);
}
/**
......@@ -61,56 +63,40 @@ class BlogsController extends Controller
$blogTags = BlogTag::getSelectData();
$blogCategories = BlogCategory::getSelectData();
return view('backend.blogs.create')->with([
'blogCategories' => $blogCategories,
'blogTags' => $blogTags,
'status' => $this->status,
]);
return new CreateResponse($this->status, $blogCategories, $blogTags);
}
/**
* @param \App\Http\Requests\Backend\Blogs\StoreBlogsRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function store(StoreBlogsRequest $request)
{
$this->blog->create($request->except('_token'));
return redirect()
->route('admin.blogs.index')
->with('flash_success', trans('alerts.backend.blogs.created'));
return new RedirectResponse(route('admin.blogs.index'), ['flash_success' => trans('alerts.backend.blogs.created')]);
}
/**
* @param \App\Models\Blogs\Blog $blog
* @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request
*
* @return mixed
* @return \App\Http\Responses\Backend\Blog\EditResponse
*/
public function edit(Blog $blog, ManageBlogsRequest $request)
{
$blogCategories = BlogCategory::getSelectData();
$blogTags = BlogTag::getSelectData();
$selectedCategories = $blog->categories->pluck('id')->toArray();
$selectedtags = $blog->tags->pluck('id')->toArray();
return view('backend.blogs.edit')->with([
'blog' => $blog,
'blogCategories' => $blogCategories,
'blogTags' => $blogTags,
'selectedCategories' => $selectedCategories,
'selectedtags' => $selectedtags,
'status' => $this->status,
]);
return new EditResponse($blog, $this->status, $blogCategories, $blogTags);
}
/**
* @param \App\Models\Blogs\Blog $blog
* @param \App\Http\Requests\Backend\Blogs\UpdateBlogsRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function update(Blog $blog, UpdateBlogsRequest $request)
{
......@@ -118,23 +104,19 @@ class BlogsController extends Controller
$this->blog->update($blog, $request->except(['_token', '_method']));
return redirect()
->route('admin.blogs.index')
->with('flash_success', trans('alerts.backend.blogs.updated'));
return new RedirectResponse(route('admin.blogs.index'), ['flash_success' => trans('alerts.backend.blogs.updated')]);
}
/**
* @param \App\Models\Blogs\Blog $blog
* @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function destroy(Blog $blog, ManageBlogsRequest $request)
{
$this->blog->delete($blog);
return redirect()
->route('admin.blogs.index')
->with('flash_success', trans('alerts.backend.blogs.deleted'));
return new RedirectResponse(route('admin.blogs.index'), ['flash_success' => trans('alerts.backend.blogs.deleted')]);
}
}
......@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
use App\Models\Access\Permission\Permission;
use App\Models\Access\Role\Role;
use App\Models\Access\User\User;
use App\Models\Settings\Setting;
use Illuminate\Http\Request;
/**
......@@ -18,7 +19,10 @@ class DashboardController extends Controller
*/
public function index()
{
return view('backend.dashboard');
$settingData = Setting::first();
$google_analytics = $settingData->google_analytics;
return view('backend.dashboard', compact('google_analytics', $google_analytics));
}
/**
......
<?php
namespace App\Http\Controllers\Backend\EmailTemplates;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\EmailTemplates\DeleteEmailTemplatesRequest;
use App\Http\Requests\Backend\EmailTemplates\EditEmailTemplatesRequest;
use App\Http\Requests\Backend\EmailTemplates\ManageEmailTemplatesRequest;
use App\Http\Requests\Backend\EmailTemplates\UpdateEmailTemplatesRequest;
use App\Models\EmailTemplatePlaceholders\EmailTemplatePlaceholder;
use App\Models\EmailTemplates\EmailTemplate;
use App\Models\EmailTemplateTypes\EmailTemplateType;
use App\Repositories\Backend\EmailTemplates\EmailTemplatesRepository;
/**
* Class EmailTemplatesController.
*/
class EmailTemplatesController extends Controller
{
/**
* @var EmailTemplatesRepository
*/
protected $emailtemplates;
/**
* __construct.
*
* @param \App\Repositories\Backend\EmailTemplates\EmailTemplatesRepository $emailtemplates
*/
public function __construct(EmailTemplatesRepository $emailtemplates)
{
$this->emailtemplates = $emailtemplates;
}
/**
* @param \App\Http\Requests\Backend\EmailTemplates\ManageEmailTemplatesRequest $request
*
* @return mixed
*/
public function index(ManageEmailTemplatesRequest $request)
{
return view('backend.emailtemplates.index');
}
/**
* @param \App\Models\EmailTemplates\EmailTemplate $emailtemplate
* @param \App\Http\Requests\Backend\EmailTemplates\EditEmailTemplatesRequest $request
*
* @return mixed
*/
public function edit(EmailTemplate $emailtemplate, EditEmailTemplatesRequest
$request)
{
$emailtemplateTypes = EmailTemplateType::getSelectData();
$emailtemplatePlaceholders = EmailTemplatePlaceholder::getSelectData();
return view('backend.emailtemplates.edit')
->withEmailtemplate($emailtemplate)
->withEmailtemplatetypes($emailtemplateTypes)
->withEmailtemplateplaceholders($emailtemplatePlaceholders);
}
/**
* @param \App\Models\EmailTemplates\EmailTemplate $emailtemplate
* @param \App\Http\Requests\Backend\EmailTemplates\UpdateEmailTemplatesRequest $request
*
* @return mixed
*/
public function update(EmailTemplate $emailtemplate, UpdateEmailTemplatesRequest
$request)
{
$this->emailtemplates->update($emailtemplate, $request->except(['_method', '_token', 'placeholder']));
return redirect()->route('admin.emailtemplates.index')
->withFlashSuccess(trans('alerts.backend.emailtemplates.updated'));
}
/**
* @param \App\Models\EmailTemplates\EmailTemplate $emailtemplate
* @param \App\Http\Requests\Backend\EmailTemplates\DeleteEmailTemplatesRequest $request
*
* @return mixed
*/
public function destroy(EmailTemplate $emailtemplate, DeleteEmailTemplatesRequest
$request)
{
$this->emailtemplates->delete($emailtemplate);
return redirect()->route('admin.emailtemplates.index')
->withFlashSuccess(trans('alerts.backend.emailtemplates.deleted'));
}
}
<?php
namespace App\Http\Controllers\Backend\EmailTemplates;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\EmailTemplates\ManageEmailTemplatesRequest;
use App\Repositories\Backend\EmailTemplates\EmailTemplatesRepository;
use Carbon\Carbon;
use Yajra\DataTables\Facades\DataTables;
/**
* Class EmailTemplatesTableController.
*/
class EmailTemplatesTableController extends Controller
{
/**
* @var EmailTemplatesRepository
*/
protected $emailtemplates;
/**
* @param \App\Repositories\Backend\EmailTemplates\EmailTemplatesRepository $emailtemplates
*/
public function __construct(EmailTemplatesRepository $emailtemplates)
{
$this->emailtemplates = $emailtemplates;
}
/**
* @param \App\Http\Requests\Backend\EmailTemplates\ManageEmailTemplatesRequest $request
*
* @return mixed
*/
public function __invoke(ManageEmailTemplatesRequest $request)
{
return Datatables::of($this->emailtemplates->getForDataTable())
->escapeColumns(['title'])
->addColumn('status', function ($emailtemplates) {
return $emailtemplates->status_label;
})
->addColumn('created_at', function ($emailtemplates) {
return Carbon::parse($emailtemplates->created_at)->toDateString();
})
->addColumn('updated_at', function ($emailtemplates) {
return Carbon::parse($emailtemplates->updated_at)->toDateString();
})
->addColumn('actions', function ($emailtemplates) {
return $emailtemplates->action_buttons;
})
->make(true);
}
}
......@@ -9,11 +9,19 @@ use App\Http\Requests\Backend\Faqs\EditFaqsRequest;
use App\Http\Requests\Backend\Faqs\ManageFaqsRequest;
use App\Http\Requests\Backend\Faqs\StoreFaqsRequest;
use App\Http\Requests\Backend\Faqs\UpdateFaqsRequest;
use App\Http\Responses\Backend\Faq\EditResponse;
use App\Http\Responses\RedirectResponse;
use App\Http\Responses\ViewResponse;
use App\Models\Faqs\Faq;
use App\Repositories\Backend\Faqs\FaqsRepository;
class FaqsController extends Controller
{
/**
* Faq Repository.
*
* @var \App\Repositories\Backend\Faqs\FaqsRepository
*/
protected $faq;
/**
......@@ -29,11 +37,11 @@ class FaqsController extends Controller
*
* @param \App\Http\Requests\Backend\Faqs\ManageFaqsRequest $request
*
* @return \Illuminate\Http\Response
* @return \App\Http\Responses\ViewResponse
*/
public function index(ManageFaqsRequest $request)
{
return view('backend.faqs.index');
return new ViewResponse('backend.faqs.index');
}
/**
......@@ -41,11 +49,11 @@ class FaqsController extends Controller
*
* @param \App\Http\Requests\Backend\Faqs\CreateFaqsRequest $request
*
* @return \Illuminate\Http\Response
* @return \App\Http\Responses\ViewResponse
*/
public function create(CreateFaqsRequest $request)
{
return view('backend.faqs.create');
return new ViewResponse('backend.faqs.create');
}
/**
......@@ -53,17 +61,13 @@ class FaqsController extends Controller
*
* @param \App\Http\Requests\Backend\Faqs\StoreFaqsRequest $request
*
* @return \Illuminate\Http\Response
* @return \App\Http\Responses\RedirectResponse
*/
public function store(StoreFaqsRequest $request)
{
$input = $request->all();
$this->faq->create($request->all());
$this->faq->create($input);
return redirect()
->route('admin.faqs.index')
->with('flash_success', trans('alerts.backend.faqs.created'));
return new RedirectResponse(route('admin.faqs.index'), ['flash_success' => trans('alerts.backend.faqs.created')]);
}
/**
......@@ -72,12 +76,11 @@ class FaqsController extends Controller
* @param \App\Models\Faqs\Faq $faq
* @param \App\Http\Requests\Backend\Faqs\EditFaqsRequest $request
*
* @return \Illuminate\Http\Response
* @return \App\Http\Responses\Backend\Faq\EditResponse
*/
public function edit(Faq $faq, EditFaqsRequest $request)
{
return view('backend.faqs.edit')
->with('faq', $faq);
return new EditResponse($faq);
}
/**
......@@ -86,17 +89,13 @@ class FaqsController extends Controller
* @param \App\Http\Requests\Backend\Faqs\UpdateFaqsRequest $request
* @param \App\Models\Faqs\Faq $id
*
* @return \Illuminate\Http\Response
* @return \App\Http\Responses\RedirectResponse
*/
public function update(UpdateFaqsRequest $request, Faq $faq)
{
$input = $request->all();
$this->faq->update($faq, $input);
$this->faq->update($faq, $request->all());
return redirect()
->route('admin.faqs.index')
->with('flash_success', trans('alerts.backend.faqs.updated'));
return new RedirectResponse(route('admin.faqs.index'), ['flash_success' => trans('alerts.backend.faqs.updated')]);
}
/**
......@@ -105,14 +104,12 @@ class FaqsController extends Controller
* @param \App\Models\Faqs\Faq $faq
* @param \App\Http\Requests\Backend\Faqs\DeleteFaqsRequest $request
*
* @return \Illuminate\Http\Response
* @return \App\Http\Responses\RedirectResponse
*/
public function destroy(Faq $faq, DeleteFaqsRequest $request)
{
$this->faq->delete($faq);
return redirect()
->route('admin.faqs.index')
->with('flash_success', trans('alerts.backend.faqs.deleted'));
return new RedirectResponse(route('admin.faqs.index'), ['flash_success' => trans('alerts.backend.faqs.deleted')]);
}
}
......@@ -9,20 +9,50 @@ use App\Http\Requests\Backend\Menu\EditMenuRequest;
use App\Http\Requests\Backend\Menu\ManageMenuRequest;
use App\Http\Requests\Backend\Menu\StoreMenuRequest;
use App\Http\Requests\Backend\Menu\UpdateMenuRequest;
use App\Http\Responses\Backend\Menu\CreateResponse;
use App\Http\Responses\Backend\Menu\EditResponse;
use App\Http\Responses\RedirectResponse;
use App\Http\Responses\ViewResponse;
use App\Models\Menu\Menu;
use App\Repositories\Backend\Menu\MenuRepository;
use Illuminate\Support\Facades\DB;
use Bvipul\Generator\Module;
class MenuController extends Controller
{
/**
* Menu Model Object.
*
* @var \App\Models\Menu\Menu
*/
protected $menu;
/**
* Module Model Object.
*
* @var \Bvipul\Generator\Module
*/
protected $modules;
/**
* Menu Types.
*
* @var array
*/
protected $types;
/**
* @param \App\Repositories\Backend\Menu\MenuRepository $menu
*/
public function __construct(MenuRepository $menu)
public function __construct(MenuRepository $menu, Module $module)
{
$this->menu = $menu;
$this->modules = $module;
$this->types = [
'backend' => 'Backend',
'frontend' => 'Frontend',
];
}
/**
......@@ -30,11 +60,11 @@ class MenuController extends Controller
*
* @param \App\Http\Requests\Backend\Menu\ManageMenuRequest $request
*
* @return \Illuminate\Http\Response
* @return \App\Http\Responses\ViewResponse
*/
public function index(ManageMenuRequest $request)
{
return view('backend.menus.index');
return new ViewResponse('backend.menus.index');
}
/**
......@@ -42,17 +72,11 @@ class MenuController extends Controller
*
* @param \App\Http\Requests\Backend\Menu\CreateMenuRequest $request
*
* @return \Illuminate\Http\Response
* @return \App\Http\Responses\Backend\Menu\CreateResponse
*/
public function create(CreateMenuRequest $request)
{
$types = [
'backend' => 'Backend',
'frontend' => 'Frontend',
];
$modules = DB::table('modules')->get();
return view('backend.menus.create')->withTypes($types)->withModules($modules);
return new CreateResponse($this->types, $this->modules);
}
/**
......@@ -60,13 +84,13 @@ class MenuController extends Controller
*
* @param \App\Http\Requests\Backend\Menu\StoreMenuRequest $request
*
* @return \Illuminate\Http\Response
* @return \App\Http\Responses\RedirectResponse
*/
public function store(StoreMenuRequest $request)
{
$this->menu->create($request->except('_token'));
return redirect()->route('admin.menus.index')->withFlashSuccess(trans('alerts.backend.menus.created'));
return new RedirectResponse(route('admin.menus.index'), ['flash_success' => trans('alerts.backend.menus.created')]);
}
/**
......@@ -75,21 +99,11 @@ class MenuController extends Controller
* @param \App\Models\Menu\Menu $menu
* @param \App\Http\Requests\Backend\Menu\EditMenuRequest $request
*
* @return \Illuminate\Http\Response
* @return \App\Http\Responses\Backend\Menu\EditResponse
*/
public function edit(Menu $menu, EditMenuRequest $request)
{
$types = [
'backend' => 'Backend',
'frontend' => 'Frontend',
];
$modules = DB::table('modules')->get();
return view('backend.menus.edit')
->with('types', $types)
->with('menu', $menu)
->with('modules', $modules);
return new EditResponse($menu, $this->types, $this->modules);
}
/**
......@@ -98,15 +112,13 @@ class MenuController extends Controller
* @param \App\Models\Menu\Menu $menu
* @param \App\Http\Requests\Backend\Menu\UpdateMenuRequest $request
*
* @return \Illuminate\Http\Response
* @return \App\Http\Responses\RedirectResponse
*/
public function update(Menu $menu, UpdateMenuRequest $request)
{
$this->menu->update($menu, $request->all());
return redirect()
->route('admin.menus.index')
->with('flash_success', trans('alerts.backend.menus.updated'));
return new RedirectResponse(route('admin.menus.index'), ['flash_success' => trans('alerts.backend.menus.updated')]);
}
/**
......@@ -115,14 +127,12 @@ class MenuController extends Controller
* @param \App\Models\Menu\Menu $menu
* @param \App\Http\Requests\Backend\Menu\DeleteMenuRequest $request
*
* @return \Illuminate\Http\Response
* @return \App\Http\Responses\RedirectResponse
*/
public function destroy(Menu $menu, DeleteMenuRequest $request)
{
$this->menu->delete($menu);
return redirect()
->route('admin.menus.index')
->with('flash_success', trans('alerts.backend.menus.deleted'));
return new RedirectResponse(route('admin.menus.index'), ['flash_success' => trans('alerts.backend.menus.deleted')]);
}
}
......@@ -12,7 +12,7 @@ use Illuminate\Support\Facades\Auth;
class NotificationController extends Controller
{
/**
* @var EmailTemplateContract
* @var \App\Repositories\Backend\Notification\NotificationRepository
*/
protected $notification;
......
......@@ -9,6 +9,9 @@ use App\Http\Requests\Backend\Pages\EditPageRequest;
use App\Http\Requests\Backend\Pages\ManagePageRequest;
use App\Http\Requests\Backend\Pages\StorePageRequest;
use App\Http\Requests\Backend\Pages\UpdatePageRequest;
use App\Http\Responses\Backend\Page\EditResponse;
use App\Http\Responses\RedirectResponse;
use App\Http\Responses\ViewResponse;
use App\Models\Page\Page;
use App\Repositories\Backend\Pages\PagesRepository;
......@@ -30,70 +33,69 @@ class PagesController extends Controller
/**
* @param \App\Http\Requests\Backend\Pages\ManagePageRequest $request
*
* @return mixed
* @return \App\Http\Responses\ViewResponse
*/
public function index(ManagePageRequest $request)
{
return view('backend.pages.index');
return new ViewResponse('backend.pages.index');
}
/**
* @param \App\Http\Requests\Backend\Pages\CreatePageRequest $request
*
* @return mixed
* @return \App\Http\Responses\ViewResponse
*/
public function create(CreatePageRequest $request)
{
return view('backend.pages.create');
return new ViewResponse('backend.pages.create');
}
/**
* @param \App\Http\Requests\Backend\Pages\StorePageRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function store(StorePageRequest $request)
{
$this->pages->create($request->except(['_token']));
return redirect()->route('admin.pages.index')->withFlashSuccess(trans('alerts.backend.pages.created'));
return new RedirectResponse(route('admin.pages.index'), ['flash_success' => trans('alerts.backend.pages.created')]);
}
/**
* @param \App\Models\Page\Page $page
* @param \App\Http\Requests\Backend\Pages\EditPageRequest $request
*
* @return mixed
* @return \App\Http\Responses\Backend\Page\EditResponse
*/
public function edit(Page $page, EditPageRequest $request)
{
return view('backend.pages.edit')
->withPage($page);
return new EditResponse($page);
}
/**
* @param \App\Models\Page\Page $page
* @param \App\Http\Requests\Backend\Pages\UpdatePageRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function update(Page $page, UpdatePageRequest $request)
{
$this->pages->update($page, $request->except(['_method', '_token']));
return redirect()->route('admin.pages.index')->withFlashSuccess(trans('alerts.backend.pages.updated'));
return new RedirectResponse(route('admin.pages.index'), ['flash_success' => trans('alerts.backend.pages.updated')]);
}
/**
* @param \App\Models\Page\Page $page
* @param \App\Http\Requests\Backend\Pages\DeletePageRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function destroy(Page $page, DeletePageRequest $request)
{
$this->pages->delete($page);
return redirect()->route('admin.pages.index')->withFlashSuccess(trans('alerts.backend.pages.deleted'));
return new RedirectResponse(route('admin.pages.index'), ['flash_success' => trans('alerts.backend.pages.deleted')]);
}
}
......@@ -5,6 +5,8 @@ namespace App\Http\Controllers\Backend\Settings;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Settings\ManageSettingsRequest;
use App\Http\Requests\Backend\Settings\UpdateSettingsRequest;
use App\Http\Responses\Backend\Setting\EditResponse;
use App\Http\Responses\RedirectResponse;
use App\Models\Settings\Setting;
use App\Repositories\Backend\Settings\SettingsRepository;
......@@ -27,26 +29,23 @@ class SettingsController extends Controller
* @param \App\Models\Settings\Setting $setting
* @param \App\Http\Requests\Backend\Settings\ManageSettingsRequest $request
*
* @return mixed
* @return \App\Http\Responses\Backend\Setting\EditResponse
*/
public function edit(Setting $setting, ManageSettingsRequest $request)
{
return view('backend.settings.edit')
->withSetting($setting);
return new EditResponse($setting);
}
/**
* @param \App\Models\Settings\Setting $setting
* @param \App\Http\Requests\Backend\Settings\UpdateSettingsRequest $request
*
* @return mixed
* @return \App\Http\Responses\RedirectResponse
*/
public function update(Setting $setting, UpdateSettingsRequest $request)
{
$this->settings->update($setting, $request->except(['_token', '_method']));
return redirect()
->route('admin.settings.edit', $setting->id)
->with('flash_success', trans('alerts.backend.settings.updated'));
return new RedirectResponse(route('admin.settings.edit', $setting->id), ['flash_success' => trans('alerts.backend.settings.updated')]);
}
}
......@@ -21,7 +21,7 @@ class LoginController extends Controller
use AuthenticatesUsers;
/**
* @var CMSPagesRepository
* @var \App\Http\Utilities\PushNotification
*/
protected $notification;
......@@ -74,7 +74,7 @@ class LoginController extends Controller
if (!$user->isConfirmed()) {
access()->logout();
throw new GeneralException(trans('exceptions.frontend.auth.confirmation.resend', ['user_id' => $user->id]));
throw new GeneralException(trans('exceptions.frontend.auth.confirmation.resend', ['user_id' => $user->id]), true);
} elseif (!$user->isActive()) {
access()->logout();
......
......@@ -95,11 +95,12 @@ class ResetPasswordController extends Controller
/**
* Get the response for a successful password reset.
*
* @param string $response
* @param \Illuminate\Http\Request $request
* @param string $response
*
* @return \Illuminate\Http\RedirectResponse
*/
protected function sendResetResponse($response)
protected function sendResetResponse($request, $response)
{
return redirect()->route(homeRoute())->withFlashSuccess(trans($response));
}
......
......@@ -4,7 +4,7 @@ namespace App\Http\Controllers\Frontend;
use App\Http\Controllers\Controller;
use App\Models\Settings\Setting;
use App\Repositories\Frontend\CMSPages\CMSPagesRepository;
use App\Repositories\Frontend\Pages\PagesRepository;
/**
* Class FrontendController.
......@@ -23,21 +23,13 @@ class FrontendController extends Controller
}
/**
* @return \Illuminate\View\View
*/
public function macros()
{
return view('frontend.macros');
}
/**
* show cmspage by pageslug.
* show page by $page_slug.
*/
public function showCMSPage($page_slug, CMSPagesRepository $RepositoryContract)
public function showPage($slug, PagesRepository $pages)
{
$result = $RepositoryContract->findBySlug($page_slug);
$result = $pages->findBySlug($slug);
return view('frontend.cmspages.index')
->withCmspages($result);
return view('frontend.pages.index')
->withpage($result);
}
}
......@@ -23,6 +23,7 @@ class Kernel extends HttpKernel
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\Spatie\Cors\Cors::class,
];
/**
......
......@@ -3,6 +3,7 @@
namespace App\Http\Middleware;
use Closure;
use Cookie;
use Illuminate\Session\Store;
/**
......@@ -39,7 +40,10 @@ class SessionTimeout
*/
public function handle($request, Closure $next)
{
if (config('session.timeout_status')) {
//Cookie Name for when 'remember me' is checked
$remember_cookie = \Auth::guard()->getRecallerName();
if (!Cookie::has($remember_cookie) && config('session.timeout_status')) {
$isLoggedIn = $request->path() != '/logout';
if (!session('lastActivityTime')) {
......
<?php
namespace App\Http\Middleware;
use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;
/**
* Class TrustProxies.
*/
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var string
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}
......@@ -12,6 +12,6 @@ class VerifyCsrfToken extends BaseVerifier
* @var array
*/
protected $except = [
//
'api/*',
];
}
<?php
namespace App\Http\Middleware;
use Closure;
use JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException;
class VerifyJWTToken
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
try {
$user = JWTAuth::parseToken()->authenticate();
} catch (JWTException $e) {
if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException) {
return response()->json(['token_expired'], $e->getStatusCode());
} elseif ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) {
return response()->json(['token_invalid'], $e->getStatusCode());
} else {
return response()->json(['error' => 'Token is required']);
}
}
return $next($request);
}
}
......@@ -27,7 +27,7 @@ class UpdateBlogCategoriesRequest extends Request
public function rules()
{
return [
'name' => 'required|max:191',
'name' => 'required|max:191|unique:blog_categories,name,'.$this->segment(3),
];
}
......@@ -39,6 +39,7 @@ class UpdateBlogCategoriesRequest extends Request
public function messages()
{
return [
'name.unique' => 'Blog category name already exists, please enter a different name.',
'name.required' => 'Blog category name must required',
'name.max' => 'Blog category may not be greater than 191 characters.',
];
......
<?php
namespace App\Http\Requests\Backend\EmailTemplates;
namespace App\Http\Requests\Backend\BlogTags;
use App\Http\Requests\Request;
/**
* Class ManageEmailTemplatesRequest.
* Class StoreBlogTagsRequest.
*/
class ManageEmailTemplatesRequest extends Request
class StoreApiBlogTagsRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
......@@ -16,7 +16,7 @@ class ManageEmailTemplatesRequest extends Request
*/
public function authorize()
{
return access()->allow('view-email-template');
return true;
}
/**
......@@ -27,7 +27,20 @@ class ManageEmailTemplatesRequest extends Request
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.',
];
}
}
......@@ -27,7 +27,7 @@ class UpdateBlogTagsRequest extends Request
public function rules()
{
return [
'name' => 'required|max:191',
'name' => 'required|max:191|unique:blog_tags,name,'.$this->segment(3),
];
}
......@@ -39,6 +39,7 @@ class UpdateBlogTagsRequest extends Request
public function messages()
{
return [
'name.unique' => 'Blog Tag name already exists, please enter a different name.',
'name.required' => 'Blog Tag name is a required field.',
'name.max' => 'Blog Tag may not be greater than 191 characters.',
];
......
......@@ -27,11 +27,12 @@ class StoreBlogsRequest extends Request
public function rules()
{
return [
'name' => 'required|max:191',
'featured_image' => 'required',
'content' => 'required',
'categories' => 'required',
'tags' => 'required',
'name' => 'required|max:191',
'featured_image' => 'required',
'publish_datetime' => 'required|date',
'content' => 'required',
'categories' => 'required',
'tags' => 'required',
];
}
......
......@@ -27,10 +27,11 @@ class UpdateBlogsRequest extends Request
public function rules()
{
return [
'name' => 'required|max:191',
'content' => 'required',
'categories' => 'required',
'tags' => 'required',
'name' => 'required|max:191|unique:blogs,name,'.$this->segment(3),
'publish_datetime' => 'required|date',
'content' => 'required',
'categories' => 'required',
'tags' => 'required',
];
}
......@@ -42,6 +43,7 @@ class UpdateBlogsRequest extends Request
public function messages()
{
return [
'name.unique' => 'Blog name already exists, please enter a different name.',
'name.required' => 'Please insert Blog Title',
'name.max' => 'Blog Title may not be greater than 191 characters.',
];
......
<?php
namespace App\Http\Requests\Backend\EmailTemplates;
use App\Http\Requests\Request;
/**
* Class DeleteEmailTemplatesRequest.
*/
class DeleteEmailTemplatesRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\EmailTemplates;
use App\Http\Requests\Request;
/**
* Class EditEmailTemplatesRequest.
*/
class EditEmailTemplatesRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('edit-email-template');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\EmailTemplates;
use App\Http\Requests\Request;
/**
* Class UpdateEmailTemplatesRequest.
*/
class UpdateEmailTemplatesRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('edit-email-template');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'title' => 'required|max:191',
'type_id' => 'required',
'subject' => 'required|max:191',
'body' => 'required',
];
}
}
......@@ -31,10 +31,6 @@ class UpdateProfileRequest extends Request
'first_name' => 'required|max:255',
'last_name' => 'required|max:255',
'email' => ['sometimes', 'required', 'email', 'max:255', Rule::unique('users')],
'state_id' => 'required',
'city_id' => 'required',
'zip_code' => 'required',
'ssn' => 'required',
];
}
}
......@@ -2,6 +2,7 @@
namespace App\Http\Requests;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Foundation\Http\FormRequest;
/**
......@@ -25,4 +26,9 @@ abstract class Request extends FormRequest
return redirect()->back()->withErrors($this->error);
}
protected function failedAuthorization()
{
throw new AuthorizationException('This action is unauthorized.');
}
}
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\Resource;
class BlogCategoriesResource 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,
'status' => ($this->isActive()) ? 'Active' : 'InActive',
'created_at' => optional($this->created_at)->toDateString(),
'created_by' => (isset($this->creator)) ? optional($this->creator)->first_name : $this->user_name,
];
}
}
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\Resource;
class BlogTagsResource 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,
'status' => ($this->isActive()) ? 'Active' : 'InActive',
'created_at' => optional($this->created_at)->toDateString(),
'created_by' => (isset($this->creator)) ? optional($this->creator)->first_name : $this->user_name,
];
}
}
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\Resource;
class BlogsResource 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,
'publish_datetime' => $this->publish_datetime->format('d/m/Y h:i A'),
'status' => $this->status,
'created_at' => optional($this->created_at)->toDateString(),
'created_by' => (is_null($this->user_name)) ? optional($this->owner)->first_name : $this->user_name,
];
}
}
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\Resource;
class FaqsResource extends Resource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
*
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'question' => $this->question,
'answer' => $this->answer,
'status' => ($this->isActive()) ? 'Active' : 'InActive',
'created_at' => $this->created_at->toDateString(),
];
}
}
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\Resource;
class PagesResource extends Resource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
*
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'title' => $this->title,
'status_label' => $this->status_label,
'status' => ($this->isActive()) ? 'Active' : 'InActive',
'created_at' => $this->created_at->toDateString(),
'created_by' => is_int($this->created_by) ? optional($this->owner)->first_name : $this->created_by,
];
}
}
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\Resource;
class PermissionResource 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,
'display_name' => $this->display_name,
'sort' => $this->sort,
'created_at' => $this->created_at->toIso8601String(),
'updated_at' => $this->updated_at->toIso8601String(),
];
}
}
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\Resource;
class RoleResource 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,
'permissions' => ($this->all) ? 'All' : optional($this->permissions)->pluck('display_name'),
'number_of_users' => $this->users->count(),
'sort' => $this->sort,
'status' => $this->status,
'created_at' => $this->created_at->toIso8601String(),
'updated_at' => $this->updated_at->toIso8601String(),
];
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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