Unverified Commit e9c76589 authored by Ruchit Patel's avatar Ruchit Patel Committed by GitHub

Merge pull request #3 from viralsolani/master

Pull from origin master laravel-adminpanel
parents 88043240 9f46d982
APP_NAME=Laravel APP_NAME="Laravel Admin Panel"
APP_ENV=local APP_ENV=local
APP_KEY=base64:O+TrollIDwasHEREtMG9kBc+/Q32exQLusNVhnq558w= APP_KEY=base64:O+TrollIDwasHEREtMG9kBc+/Q32exQLusNVhnq558w=
APP_DEBUG=true APP_DEBUG=true
...@@ -12,6 +12,10 @@ DB_DATABASE=homestead ...@@ -12,6 +12,10 @@ DB_DATABASE=homestead
DB_USERNAME=homestead DB_USERNAME=homestead
DB_PASSWORD=secret DB_PASSWORD=secret
# Access
ENABLE_REGISTRATION=true
REQUIRES_APPROVAL=false
BROADCAST_DRIVER=log BROADCAST_DRIVER=log
CACHE_DRIVER=file CACHE_DRIVER=file
SESSION_DRIVER=file SESSION_DRIVER=file
......
...@@ -25,4 +25,5 @@ phpunit.txt ...@@ -25,4 +25,5 @@ phpunit.txt
public/css public/css
public/js public/js
composer.lock composer.lock
/public/img/backend/blog_images public/img/backend/blog_images/*
\ No newline at end of file public/mix-manifest.json
\ No newline at end of file
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Console\DetectsApplicationNamespace;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Artisan;
class ModuleGenerator extends Command
{
use DetectsApplicationNamespace;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'generate:module {--model= : Model Name} {--controller= : Name of the controller} {--t= : If table Controller should be made} {--res : If the controller should be resourceful} {--table= : Name of the table} {--routes= : Route Name} {--route_controller= : Route Controller} {--views= : If the views should be made} {--el= : If events and listeners should be made} {--repo= : If Repository should be made}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'It creates module\'s basic scaffolding like (Controllers, Model, Migration, Routes and Views)';
/**
* The filesystem instance.
*
* @var \Illuminate\Filesystem\Filesystem
*/
protected $files;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct(Filesystem $files)
{
parent::__construct();
$this->files = $files;
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//Making model
if ($this->option('model')) {
$model = $this->parseModel($this->option('model'));
$a = Artisan::call('make:model', ['name' => $model]);
$this->line(Artisan::output());
}
//Making Controller
if ($this->option('controller')) {
$controller = $this->parseModel($this->option('controller'));
Artisan::call('make:controller', ['name' => $controller, '--resource' => $this->option('res')]);
$this->line(Artisan::output());
//Making Table Controller
if ($this->option('t')) {
$tableController = $this->parseModel($this->option('t'));
Artisan::call('make:controller', ['name' => $tableController]);
$this->line('Table '.Artisan::output());
}
}
//Making Migration
if ($table = $this->option('table')) {
Artisan::call('make:migration', [
'name' => 'create_'.$table.'_table',
'--create' => $table,
]);
$this->line(Artisan::output());
}
//Making Events and Listeners
if ($this->option('el')) {
$el = explode(',', $this->option('el'));
foreach ($el as $e) {
$event = $this->parseModel($e);
Artisan::call('make:event', [
'name' => $event,
]);
$this->line(Artisan::output());
Artisan::call('make:listener', [
'name' => $event.'Listener',
'--event' => $event,
]);
$this->line(Artisan::output());
}
}
//Creating Routes
if (($route_name = $this->option('routes')) && $this->option('route_controller')) {
$base_path = base_path('routes/Backend');
$controller = class_basename($this->option('controller'));
if ($this->option('model')) {
$filename = class_basename($this->option('model'));
} else {
$filename = ucfirst($route_name);
}
$this->checkAndCreateDir($base_path);
$file_content = $this->files->get($this->getStub($this->option('res') ? 'resource' : false));
$file_content = str_replace(
['dummy_name', 'DummyModel', 'DummyController'],
[$route_name, $filename, $controller],
$file_content
);
$this->files->put($base_path.'/'.$filename.'.php', $file_content);
$this->line('Route File generated Successfully');
}
//Creating Views
if ($this->option('views')) {
$view_folder_name = strtolower($this->option('views'));
$base_path = resource_path('views/backend');
$path = $base_path.'/'.$view_folder_name;
$this->checkAndCreateDir($path);
$this->createViewFiles($path);
$this->line('View Files generated successfully');
}
//Creating Repository
if ($repo = $this->option('repo')) {
$class_name = class_basename($repo);
$repo = str_replace($class_name, '', $repo);
$base_path = base_path('app/Repositories/'.$repo);
$this->checkAndCreateDir($base_path);
$this->createRepoFile($repo, $class_name);
$this->line('Repository generated successfully');
}
}
/**
* Creating REpository File.
*
* @param string $path
* @param string $class
*
* @return none
*/
public function createRepoFile($path, $class)
{
$rootNamespace = $this->laravel->getNamespace().'Repositories\\';
$newPath = str_replace('/', '\\', $path);
$namespace = trim(str_replace('/', '\\', $rootNamespace.$newPath), '\\');
$file_contents = $this->files->get(__DIR__.'/Stubs/repository.stub');
$file_contents = str_replace(
['DummyNamespace', 'DummyClass'],
[$namespace, $class],
$file_contents
);
$path = base_path('app/Repositories/'.$path.'/'.$class);
$this->files->put($path, $file_contents);
}
/**
* Creating View Files (index, create, edit, form).
*
* @param string $path
*
* @return none
*/
public function createViewFiles($path)
{
$files = ['/index.blade.php', '/create.blade.php', '/edit.blade.php', '/form.blade.php'];
foreach ($files as $file) {
$this->files->put($path.$file, $this->files->get($this->getStub(false, true)));
}
}
/**
* Return Stub.
*
* @param bool $res
*
* @return file
*/
public function getStub($res = false, $view = false)
{
if ($view) {
return __DIR__.'/Stubs/view.stub';
} else {
if ($res && $res == 'resource') {
return __DIR__.'/Stubs/resourceRoute.stub';
} else {
return __DIR__.'/Stubs/route.stub';
}
}
}
/**
* Creating Directory.
*
* @param string $model
*
* @return string
*/
public function checkAndCreateDir($path)
{
if (is_dir($path)) {
return $path;
}
mkdir($path, 0777, true);
return $path;
}
/**
* Get the fully-qualified model class name.
*
* @param string $model
*
* @return string
*/
protected function parseModel($model)
{
if (preg_match('([^A-Za-z0-9_/\\\\])', $model)) {
throw new InvalidArgumentException('Name contains invalid characters.');
}
$model = trim(str_replace('/', '\\', $model), '\\');
return $model;
}
}
...@@ -13,7 +13,6 @@ class Kernel extends ConsoleKernel ...@@ -13,7 +13,6 @@ class Kernel extends ConsoleKernel
* @var array * @var array
*/ */
protected $commands = [ protected $commands = [
'App\Console\Commands\ModuleGenerator',
]; ];
/** /**
......
...@@ -14,13 +14,13 @@ class BlogCategoryCreated ...@@ -14,13 +14,13 @@ class BlogCategoryCreated
/** /**
* @var * @var
*/ */
public $blogcategories; public $blogcategory;
/** /**
* @param $blogcategories * @param $blogcategory
*/ */
public function __construct($blogcategories) public function __construct($blogcategory)
{ {
$this->blogcategories = $blogcategories; $this->blogcategory = $blogcategory;
} }
} }
...@@ -14,13 +14,13 @@ class BlogCategoryDeleted ...@@ -14,13 +14,13 @@ class BlogCategoryDeleted
/** /**
* @var * @var
*/ */
public $blogcategories; public $blogcategory;
/** /**
* @param $blogcategories * @param $blogcategory
*/ */
public function __construct($blogcategories) public function __construct($blogcategory)
{ {
$this->blogcategories = $blogcategories; $this->blogcategory = $blogcategory;
} }
} }
...@@ -14,13 +14,13 @@ class BlogCategoryUpdated ...@@ -14,13 +14,13 @@ class BlogCategoryUpdated
/** /**
* @var * @var
*/ */
public $blogcategories; public $blogcategory;
/** /**
* @param $blogcategories * @param $blogcategory
*/ */
public function __construct($blogcategories) public function __construct($blogcategory)
{ {
$this->blogcategories = $blogcategories; $this->blogcategory = $blogcategory;
} }
} }
...@@ -14,13 +14,13 @@ class BlogTagCreated ...@@ -14,13 +14,13 @@ class BlogTagCreated
/** /**
* @var * @var
*/ */
public $blogtags; public $blogtag;
/** /**
* @param $blogtags * @param $blogtag
*/ */
public function __construct($blogtags) public function __construct($blogtag)
{ {
$this->blogtags = $blogtags; $this->blogtag = $blogtag;
} }
} }
...@@ -14,13 +14,13 @@ class BlogTagDeleted ...@@ -14,13 +14,13 @@ class BlogTagDeleted
/** /**
* @var * @var
*/ */
public $blogtags; public $blogtag;
/** /**
* @param $blogtags * @param $blogtag
*/ */
public function __construct($blogtags) public function __construct($blogtag)
{ {
$this->blogtags = $blogtags; $this->blogtag = $blogtag;
} }
} }
...@@ -14,13 +14,13 @@ class BlogTagUpdated ...@@ -14,13 +14,13 @@ class BlogTagUpdated
/** /**
* @var * @var
*/ */
public $blogtags; public $blogtag;
/** /**
* @param $blogtags * @param $blogtag
*/ */
public function __construct($blogtags) public function __construct($blogtag)
{ {
$this->blogtags = $blogtags; $this->blogtag = $blogtag;
} }
} }
...@@ -17,6 +17,25 @@ function generateUuid() ...@@ -17,6 +17,25 @@ function generateUuid()
return uuid::uuid4(); return uuid::uuid4();
} }
if (!function_exists('homeRoute')) {
/**
* Return the route to the "home" page depending on authentication/authorization status.
*
* @return string
*/
function homeRoute()
{
if (access()->allow('view-backend')) {
return 'admin.dashboard';
} elseif (auth()->check()) {
return 'frontend.user.dashboard';
}
return 'frontend.index';
}
}
/* /*
* Global helpers file with misc functions. * Global helpers file with misc functions.
*/ */
......
...@@ -15,4 +15,5 @@ require __DIR__.'/Blog_Category.php'; ...@@ -15,4 +15,5 @@ require __DIR__.'/Blog_Category.php';
require __DIR__.'/Blog_Tag.php'; require __DIR__.'/Blog_Tag.php';
require __DIR__.'/Blog_Management.php'; require __DIR__.'/Blog_Management.php';
require __DIR__.'/Faqs.php'; require __DIR__.'/Faqs.php';
require __DIR__.'/Menu.php';
require __DIR__.'/LogViewer.php'; require __DIR__.'/LogViewer.php';
<?php
Breadcrumbs::register('admin.menus.index', function ($breadcrumbs) {
$breadcrumbs->parent('admin.dashboard');
$breadcrumbs->push(trans('menus.backend.menus.management'), route('admin.menus.index'));
});
Breadcrumbs::register('admin.menus.create', function ($breadcrumbs) {
$breadcrumbs->parent('admin.menus.index');
$breadcrumbs->push(trans('menus.backend.menus.create'), route('admin.menus.create'));
});
Breadcrumbs::register('admin.menus.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.menus.index');
$breadcrumbs->push(trans('menus.backend.menus.edit'), route('admin.menus.edit', $id));
});
...@@ -17,21 +17,18 @@ use App\Repositories\Backend\BlogCategories\BlogCategoriesRepository; ...@@ -17,21 +17,18 @@ use App\Repositories\Backend\BlogCategories\BlogCategoriesRepository;
*/ */
class BlogCategoriesController extends Controller class BlogCategoriesController extends Controller
{ {
/** protected $blogcategory;
* @var BlogCategoriesRepository
*/
protected $blogcategories;
/** /**
* @param BlogCategoriesRepository $blogcategories * @param BlogCategoriesRepository $blogcategory
*/ */
public function __construct(BlogCategoriesRepository $blogcategories) public function __construct(BlogCategoriesRepository $blogcategory)
{ {
$this->blogcategories = $blogcategories; $this->blogcategory = $blogcategory;
} }
/** /**
* @param ManageBlogCategoriesRequest $request * @param \App\Http\Requests\Backend\BlogCategories\ManageBlogCategoriesRequest $request
* *
* @return mixed * @return mixed
*/ */
...@@ -41,7 +38,7 @@ class BlogCategoriesController extends Controller ...@@ -41,7 +38,7 @@ class BlogCategoriesController extends Controller
} }
/** /**
* @param CreateBlogCategoriesRequest $request * @param \App\Http\Requests\Backend\BlogCategories\CreateBlogCategoriesRequest $request
* *
* @return mixed * @return mixed
*/ */
...@@ -51,52 +48,58 @@ class BlogCategoriesController extends Controller ...@@ -51,52 +48,58 @@ class BlogCategoriesController extends Controller
} }
/** /**
* @param StoreBlogCategoriesRequest $request * @param \App\Http\Requests\Backend\BlogCategories\StoreBlogCategoriesRequest $request
* *
* @return mixed * @return mixed
*/ */
public function store(StoreBlogCategoriesRequest $request) public function store(StoreBlogCategoriesRequest $request)
{ {
$this->blogcategories->create($request->all()); $this->blogcategory->create($request->all());
return redirect()->route('admin.blogcategories.index')->withFlashSuccess(trans('alerts.backend.blogcategories.created')); return redirect()
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.created'));
} }
/** /**
* @param BlogCategory $blogcategory * @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param EditBlogCategoriesRequest $request * @param \App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest $request
* *
* @return mixed * @return mixed
*/ */
public function edit(BlogCategory $blogcategory, EditBlogCategoriesRequest $request) public function edit(BlogCategory $blogCategory, EditBlogCategoriesRequest $request)
{ {
return view('backend.blogcategories.edit') return view('backend.blogcategories.edit')
->withBlogcategory($blogcategory); ->with('blogcategory', $blogCategory);
} }
/** /**
* @param BlogCategory $blogcategory * @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param UpdateBlogCategoriesRequest $request * @param \App\Http\Requests\Backend\BlogCategories\UpdateBlogCategoriesRequest $request
* *
* @return mixed * @return mixed
*/ */
public function update(BlogCategory $blogcategory, UpdateBlogCategoriesRequest $request) public function update(BlogCategory $blogCategory, UpdateBlogCategoriesRequest $request)
{ {
$this->blogcategories->update($blogcategory, $request->all()); $this->blogcategory->update($blogCategory, $request->all());
return redirect()->route('admin.blogcategories.index')->withFlashSuccess(trans('alerts.backend.blogcategories.updated')); return redirect()
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.updated'));
} }
/** /**
* @param BlogCategory $blogcategory * @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param DeleteBlogCategoriesRequest $request * @param \App\Http\Requests\Backend\BlogCategories\DeleteBlogCategoriesRequest $request
* *
* @return mixed * @return mixed
*/ */
public function destroy(BlogCategory $blogcategory, DeleteBlogCategoriesRequest $request) public function destroy(BlogCategory $blogCategory, DeleteBlogCategoriesRequest $request)
{ {
$this->blogcategories->delete($blogcategory); $this->blogcategory->delete($blogCategory);
return redirect()->route('admin.blogcategories.index')->withFlashSuccess(trans('alerts.backend.blogcategories.deleted')); return redirect()
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.deleted'));
} }
} }
...@@ -13,43 +13,36 @@ use Yajra\DataTables\Facades\DataTables; ...@@ -13,43 +13,36 @@ use Yajra\DataTables\Facades\DataTables;
*/ */
class BlogCategoriesTableController extends Controller class BlogCategoriesTableController extends Controller
{ {
/** protected $blogcategory;
* @var BlogCategoriesRepository
*/
protected $blogcategories;
/** /**
* @param BlogCategoriesRepository $cmspages * @param \App\Repositories\Backend\BlogCategories\BlogCategoriesRepository $cmspages
*/ */
public function __construct(BlogCategoriesRepository $blogcategories) public function __construct(BlogCategoriesRepository $blogcategory)
{ {
$this->blogcategories = $blogcategories; $this->blogcategory = $blogcategory;
} }
/** /**
* @param ManageBlogCategoriesRequest $request * @param \App\Http\Requests\Backend\BlogCategories\ManageBlogCategoriesRequest $request
* *
* @return mixed * @return mixed
*/ */
public function __invoke(ManageBlogCategoriesRequest $request) public function __invoke(ManageBlogCategoriesRequest $request)
{ {
return Datatables::of($this->blogcategories->getForDataTable()) return Datatables::of($this->blogcategory->getForDataTable())
->escapeColumns(['name']) ->escapeColumns(['name'])
->addColumn('status', function ($blogcategories) { ->addColumn('status', function ($blogcategory) {
if ($blogcategories->status) { return $blogcategory->status_label;
return '<span class="label label-success">Active</span>';
}
return '<span class="label label-danger">Inactive</span>';
}) })
->addColumn('created_by', function ($blogcategories) { ->addColumn('created_by', function ($blogcategory) {
return $blogcategories->user_name; return $blogcategory->user_name;
}) })
->addColumn('created_at', function ($blogcategories) { ->addColumn('created_at', function ($blogcategory) {
return Carbon::parse($blogcategories->created_at)->toDateString(); return Carbon::parse($blogcategory->created_at)->toDateString();
}) })
->addColumn('actions', function ($blogcategories) { ->addColumn('actions', function ($blogcategory) {
return $blogcategories->action_buttons; return $blogcategory->action_buttons;
}) })
->make(true); ->make(true);
} }
......
...@@ -18,20 +18,20 @@ use App\Repositories\Backend\BlogTags\BlogTagsRepository; ...@@ -18,20 +18,20 @@ use App\Repositories\Backend\BlogTags\BlogTagsRepository;
class BlogTagsController extends Controller class BlogTagsController extends Controller
{ {
/** /**
* @var BlogTagsRepository * @var \App\Repositories\Backend\BlogTags\BlogTagsRepository
*/ */
protected $blogtags; protected $blogtag;
/** /**
* @param blogtagsRepository $blogtags * @param \App\Repositories\Backend\BlogTags\BlogTagsRepository $blogtag
*/ */
public function __construct(BlogTagsRepository $blogtags) public function __construct(BlogTagsRepository $blogtag)
{ {
$this->blogtags = $blogtags; $this->blogtag = $blogtag;
} }
/** /**
* @param ManageBlogTagsRequest $request * @param \App\Http\Requests\Backend\BlogTags\ManageBlogTagsRequest $request
* *
* @return mixed * @return mixed
*/ */
...@@ -41,7 +41,7 @@ class BlogTagsController extends Controller ...@@ -41,7 +41,7 @@ class BlogTagsController extends Controller
} }
/** /**
* @param CreateBlogTagsRequest $request * @param \App\Http\Requests\Backend\BlogTags\CreateBlogTagsRequest $request
* *
* @return mixed * @return mixed
*/ */
...@@ -51,52 +51,58 @@ class BlogTagsController extends Controller ...@@ -51,52 +51,58 @@ class BlogTagsController extends Controller
} }
/** /**
* @param StoreblogtagsRequest $request * @param \App\Http\Requests\Backend\BlogTags\StoreBlogTagsRequest $request
* *
* @return mixed * @return mixed
*/ */
public function store(StoreBlogTagsRequest $request) public function store(StoreBlogTagsRequest $request)
{ {
$this->blogtags->create($request->all()); $this->blogtag->create($request->except('token'));
return redirect()->route('admin.blogtags.index')->withFlashSuccess(trans('alerts.backend.blogtags.created')); return redirect()
->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.created'));
} }
/** /**
* @param BlogTag $blogtag * @param \App\Models\BlogTags\BlogTag $blogTag
* @param EditBlogTagsRequest $request * @param \App\Http\Requests\Backend\BlogTags\EditBlogTagsRequest $request
* *
* @return mixed * @return mixed
*/ */
public function edit(BlogTag $blogtag, EditBlogTagsRequest $request) public function edit(BlogTag $blogTag, EditBlogTagsRequest $request)
{ {
return view('backend.blogtags.edit') return view('backend.blogtags.edit')
->withBlogtag($blogtag); ->with('blogtag', $blogTag);
} }
/** /**
* @param BlogTag $blogtag * @param \App\Models\BlogTags\BlogTag $blogTag
* @param UpdateblogtagsRequest $request * @param \App\Http\Requests\Backend\BlogTags\UpdateBlogTagsRequest $request
* *
* @return mixed * @return mixed
*/ */
public function update(BlogTag $blogtag, UpdateBlogTagsRequest $request) public function update(BlogTag $blogTag, UpdateBlogTagsRequest $request)
{ {
$this->blogtags->update($blogtag, $request->all()); $this->blogtag->update($blogTag, $request->except(['_method', '_token']));
return redirect()->route('admin.blogtags.index')->withFlashSuccess(trans('alerts.backend.blogtags.updated')); return redirect()
->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.updated'));
} }
/** /**
* @param BlogTag $blogtag * @param \App\Models\BlogTags\BlogTag $blogTag
* @param DeleteBlogTagsRequest $request * @param \App\Http\Requests\Backend\BlogTags\DeleteBlogTagsRequest $request
* *
* @return mixed * @return mixed
*/ */
public function destroy(BlogTag $blogtag, DeleteBlogTagsRequest $request) public function destroy(BlogTag $blogTag, DeleteBlogTagsRequest $request)
{ {
$this->blogtags->delete($blogtag); $this->blogtag->delete($blogTag);
return redirect()->route('admin.blogtags.index')->withFlashSuccess(trans('alerts.backend.blogtags.deleted')); return redirect()
->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.deleted'));
} }
} }
...@@ -14,12 +14,12 @@ use Yajra\DataTables\Facades\DataTables; ...@@ -14,12 +14,12 @@ use Yajra\DataTables\Facades\DataTables;
class BlogTagsTableController extends Controller class BlogTagsTableController extends Controller
{ {
/** /**
* @var BlogTagsRepository * @var \App\Repositories\Backend\BlogTags\BlogTagsRepository
*/ */
protected $blogtags; protected $blogtags;
/** /**
* @param BlogTagsRepository $cmspages * @param \App\Repositories\Backend\BlogTags\BlogTagsRepository $blogtags
*/ */
public function __construct(BlogTagsRepository $blogtags) public function __construct(BlogTagsRepository $blogtags)
{ {
...@@ -27,7 +27,7 @@ class BlogTagsTableController extends Controller ...@@ -27,7 +27,7 @@ class BlogTagsTableController extends Controller
} }
/** /**
* @param ManageBlogTagsRequest $request * @param \App\Http\Requests\Backend\BlogTags\ManageBlogTagsRequest $request
* *
* @return mixed * @return mixed
*/ */
...@@ -36,11 +36,7 @@ class BlogTagsTableController extends Controller ...@@ -36,11 +36,7 @@ class BlogTagsTableController extends Controller
return Datatables::of($this->blogtags->getForDataTable()) return Datatables::of($this->blogtags->getForDataTable())
->escapeColumns(['name']) ->escapeColumns(['name'])
->addColumn('status', function ($blogtags) { ->addColumn('status', function ($blogtags) {
if ($blogtags->status) { return $blogtags->status_label;
return '<span class="label label-success">Active</span>';
}
return '<span class="label label-danger">Inactive</span>';
}) })
->addColumn('created_by', function ($blogtags) { ->addColumn('created_by', function ($blogtags) {
return $blogtags->user_name; return $blogtags->user_name;
......
...@@ -16,175 +16,125 @@ use App\Repositories\Backend\Blogs\BlogsRepository; ...@@ -16,175 +16,125 @@ use App\Repositories\Backend\Blogs\BlogsRepository;
*/ */
class BlogsController extends Controller class BlogsController extends Controller
{ {
/**
* Blog Status.
*/
protected $status = [
'Published' => 'Published',
'Draft' => 'Draft',
'InActive' => 'InActive',
'Scheduled' => 'Scheduled',
];
/** /**
* @var BlogsRepository * @var BlogsRepository
*/ */
protected $blogs; protected $blog;
/** /**
* @param BlogsRepository $blogs * @param \App\Repositories\Backend\Blogs\BlogsRepository $blog
*/ */
public function __construct(BlogsRepository $blogs) public function __construct(BlogsRepository $blog)
{ {
$this->blogs = $blogs; $this->blog = $blog;
} }
/** /**
* @param ManageBlogsRequest $request * @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request
* *
* @return mixed * @return mixed
*/ */
public function index(ManageBlogsRequest $request) public function index(ManageBlogsRequest $request)
{ {
$status = [ return view('backend.blogs.index')->with([
'Published' => 'Published', 'status'=> $this->status,
'Draft' => 'Draft', ]);
'Inactive' => 'Inactive',
'Scheduled' => 'Scheduled',
];
return view('backend.blogs.index', compact('status'));
} }
/** /**
* @param ManageBlogsRequest $request * @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request
* *
* @return mixed * @return mixed
*/ */
public function create(ManageBlogsRequest $request) public function create(ManageBlogsRequest $request)
{ {
$blogCategories = BlogCategory::where('status', 1)->pluck('name', 'id'); $blogTags = BlogTag::getSelectData();
$blogTags = BlogTag::where('status', 1)->pluck('name', 'id'); $blogCategories = BlogCategory::getSelectData();
$status = [
'Published' => 'Published', return view('backend.blogs.create')->with([
'Draft' => 'Draft', 'blogCategories' => $blogCategories,
'Inactive' => 'Inactive', 'blogTags' => $blogTags,
'Scheduled' => 'Scheduled', 'status' => $this->status,
]; ]);
return view('backend.blogs.create', compact('blogCategories', 'blogTags', 'status'));
} }
/** /**
* @param StoreBlogsRequest $request * @param \App\Http\Requests\Backend\Blogs\StoreBlogsRequest $request
* *
* @return mixed * @return mixed
*/ */
public function store(StoreBlogsRequest $request) public function store(StoreBlogsRequest $request)
{ {
$input = $request->all(); $this->blog->create($request->except('_token'));
$tagsArray = $this->createTagsArray($input['tags']);
$categoriesArray = $this->createCategoriesArray($input['categories']);
$this->blogs->create($input, $tagsArray, $categoriesArray);
return redirect()->route('admin.blogs.index')->withFlashSuccess(trans('alerts.backend.blogs.created')); return redirect()
->route('admin.blogs.index')
->with('flash_success', trans('alerts.backend.blogs.created'));
} }
/** /**
* @param Blog $blog * @param \App\Models\Blogs\Blog $blog
* @param ManageBlogsRequest $request * @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request
* *
* @return mixed * @return mixed
*/ */
public function edit(Blog $blog, ManageBlogsRequest $request) public function edit(Blog $blog, ManageBlogsRequest $request)
{ {
$blogCategories = BlogCategory::where('status', 1)->pluck('name', 'id'); $blogCategories = BlogCategory::getSelectData();
$blogTags = BlogTag::where('status', 1)->pluck('name', 'id'); $blogTags = BlogTag::getSelectData();
$status = [
'Published' => 'Published',
'Draft' => 'Draft',
'InActive' => 'InActive',
'Scheduled' => 'Scheduled',
];
$selectedCategories = $blog->categories->pluck('id')->toArray(); $selectedCategories = $blog->categories->pluck('id')->toArray();
$selectedtags = $blog->tags->pluck('id')->toArray(); $selectedtags = $blog->tags->pluck('id')->toArray();
return view('backend.blogs.edit', compact( return view('backend.blogs.edit')->with([
'blogCategories', 'blog' => $blog,
'blogTags', 'blogCategories' => $blogCategories,
'status', 'blogTags' => $blogTags,
'selectedCategories', 'selectedCategories' => $selectedCategories,
'selectedtags') 'selectedtags' => $selectedtags,
) 'status' => $this->status,
->withBlog($blog); ]);
} }
/** /**
* @param Blog $blog * @param \App\Models\Blogs\Blog $blog
* @param UpdateBlogsRequest $request * @param \App\Http\Requests\Backend\Blogs\UpdateBlogsRequest $request
* *
* @return mixed * @return mixed
*/ */
public function update(Blog $blog, UpdateBlogsRequest $request) public function update(Blog $blog, UpdateBlogsRequest $request)
{ {
$input = $request->all(); $input = $request->all();
$tagsArray = $this->createTagsArray($input['tags']);
$categoriesArray = $this->createCategoriesArray($input['categories']);
$this->blogs->update($blog, $input, $tagsArray, $categoriesArray); $this->blog->update($blog, $request->except(['_token', '_method']));
return redirect()->route('admin.blogs.index')->withFlashSuccess(trans('alerts.backend.blogs.updated')); return redirect()
->route('admin.blogs.index')
->with('flash_success', trans('alerts.backend.blogs.updated'));
} }
/** /**
* @param Blog $blog * @param \App\Models\Blogs\Blog $blog
* @param ManageBlogsRequest $request * @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request
* *
* @return mixed * @return mixed
*/ */
public function destroy(Blog $blog, ManageBlogsRequest $request) public function destroy(Blog $blog, ManageBlogsRequest $request)
{ {
$this->blogs->delete($blog); $this->blog->delete($blog);
return redirect()->route('admin.blogs.index')->withFlashSuccess(trans('alerts.backend.blogs.deleted'));
}
/**
* Creating Tags Array.
*
* @param Array($tags)
*
* @return array
*/
public function createTagsArray($tags)
{
//Creating a new array for tags (newly created)
$tags_array = [];
foreach ($tags as $tag) {
if (is_numeric($tag)) {
$tags_array[] = $tag;
} else {
$newTag = BlogTag::create(['name' => $tag, 'status' => 1, 'created_by' => 1]);
$tags_array[] = $newTag->id;
}
}
return $tags_array;
}
/**
* Creating Tags Array.
*
* @param Array($tags)
*
* @return array
*/
public function createCategoriesArray($categories)
{
//Creating a new array for categories (newly created)
$categories_array = [];
foreach ($categories as $category) {
if (is_numeric($category)) {
$categories_array[] = $category;
} else {
$newCategory = BlogCategory::create(['name' => $category, 'status' => 1, 'created_by' => 1]);
$categories_array[] = $newCategory->id;
}
}
return $categories_array; return redirect()
->route('admin.blogs.index')
->with('flash_success', trans('alerts.backend.blogs.deleted'));
} }
} }
...@@ -5,7 +5,6 @@ namespace App\Http\Controllers\Backend\Blogs; ...@@ -5,7 +5,6 @@ namespace App\Http\Controllers\Backend\Blogs;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Blogs\ManageBlogsRequest; use App\Http\Requests\Backend\Blogs\ManageBlogsRequest;
use App\Repositories\Backend\Blogs\BlogsRepository; use App\Repositories\Backend\Blogs\BlogsRepository;
use Carbon\Carbon;
use Yajra\DataTables\Facades\DataTables; use Yajra\DataTables\Facades\DataTables;
/** /**
...@@ -13,13 +12,10 @@ use Yajra\DataTables\Facades\DataTables; ...@@ -13,13 +12,10 @@ use Yajra\DataTables\Facades\DataTables;
*/ */
class BlogsTableController extends Controller class BlogsTableController extends Controller
{ {
/**
* @var BlogsRepository
*/
protected $blogs; protected $blogs;
/** /**
* @param BlogsRepository $cmspages * @param \App\Repositories\Backend\Blogs\BlogsRepository $cmspages
*/ */
public function __construct(BlogsRepository $blogs) public function __construct(BlogsRepository $blogs)
{ {
...@@ -27,7 +23,7 @@ class BlogsTableController extends Controller ...@@ -27,7 +23,7 @@ class BlogsTableController extends Controller
} }
/** /**
* @param ManageBlogsRequest $request * @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request
* *
* @return mixed * @return mixed
*/ */
...@@ -39,13 +35,13 @@ class BlogsTableController extends Controller ...@@ -39,13 +35,13 @@ class BlogsTableController extends Controller
return $blogs->status; return $blogs->status;
}) })
->addColumn('publish_datetime', function ($blogs) { ->addColumn('publish_datetime', function ($blogs) {
return Carbon::parse($blogs->publish_datetime)->format('d/m/Y h:i A'); return $blogs->publish_datetime->format('d/m/Y h:i A');
}) })
->addColumn('created_by', function ($blogs) { ->addColumn('created_by', function ($blogs) {
return $blogs->user_name; return $blogs->user_name;
}) })
->addColumn('created_at', function ($blogs) { ->addColumn('created_at', function ($blogs) {
return Carbon::parse($blogs->created_at)->toDateString(); return $blogs->created_at->toDateString();
}) })
->addColumn('actions', function ($blogs) { ->addColumn('actions', function ($blogs) {
return $blogs->action_buttons; return $blogs->action_buttons;
......
...@@ -44,12 +44,6 @@ class DashboardController extends Controller ...@@ -44,12 +44,6 @@ class DashboardController extends Controller
$user = User::find($userId); $user = User::find($userId);
$user->first_name = $input['first_name']; $user->first_name = $input['first_name'];
$user->last_name = $input['last_name']; $user->last_name = $input['last_name'];
$user->address = $input['address'];
$user->state_id = $input['state_id'];
$user->country_id = config('access.constants.default_country');
$user->city_id = $input['city_id'];
$user->zip_code = $input['zip_code'];
$user->ssn = $input['ssn'];
$user->updated_by = access()->user()->id; $user->updated_by = access()->user()->id;
if ($user->save()) { if ($user->save()) {
......
<?php
namespace App\Http\Controllers\Backend\Faqs;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Faqs\EditFaqsRequest;
use App\Models\Faqs\Faq;
use App\Repositories\Backend\Faqs\FaqsRepository;
class FaqStatusController extends Controller
{
protected $faq;
/**
* @param \App\Repositories\Backend\Faqs\FaqsRepository $faq
*/
public function __construct(FaqsRepository $faq)
{
$this->faq = $faq;
}
/**
* @param \App\Models\Faqs\Faq $Faq
* @param $status
* @param \App\Http\Requests\Backend\Faqs\ManageFaqsRequest $request
*
* @return mixed
*/
public function store(Faq $faq, $status, EditFaqsRequest $request)
{
$this->faq->mark($faq, $status);
return redirect()
->route('admin.faqs.index')
->with('flash_success', trans('alerts.backend.faqs.updated'));
}
}
...@@ -14,35 +14,33 @@ use App\Repositories\Backend\Faqs\FaqsRepository; ...@@ -14,35 +14,33 @@ use App\Repositories\Backend\Faqs\FaqsRepository;
class FaqsController extends Controller class FaqsController extends Controller
{ {
/** protected $faq;
* @var FaqsRepository
*/
protected $faqs;
/** /**
* @param FaqsRepository $faqs * @param \App\Repositories\Backend\Faqs\FaqsRepository $faq
*/ */
public function __construct(FaqsRepository $faqs) public function __construct(FaqsRepository $faq)
{ {
$this->faqs = $faqs; $this->faq = $faq;
} }
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* *
* @param \App\Http\Requests\Backend\Faqs\ManageFaqsRequest $request
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function index(ManageFaqsRequest $request) public function index(ManageFaqsRequest $request)
{ {
//Status array return view('backend.faqs.index');
$status = [1 => 'Active', 0 => 'Inactive'];
return view('backend.faqs.index')->withStatus($status);
} }
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* *
* @param \App\Http\Requests\Backend\Faqs\CreateFaqsRequest $request
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function create(CreateFaqsRequest $request) public function create(CreateFaqsRequest $request)
...@@ -53,7 +51,7 @@ class FaqsController extends Controller ...@@ -53,7 +51,7 @@ class FaqsController extends Controller
/** /**
* Store a newly created resource in storage. * Store a newly created resource in storage.
* *
* @param \Illuminate\Http\Request $request * @param \App\Http\Requests\Backend\Faqs\StoreFaqsRequest $request
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
...@@ -61,39 +59,32 @@ class FaqsController extends Controller ...@@ -61,39 +59,32 @@ class FaqsController extends Controller
{ {
$input = $request->all(); $input = $request->all();
$this->faqs->create($input); $this->faq->create($input);
return redirect()->route('admin.faqs.index')->withFlashSuccess(trans('alerts.backend.faqs.created')); return redirect()
} ->route('admin.faqs.index')
->with('flash_success', trans('alerts.backend.faqs.created'));
/**
* Display the specified resource.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show($id)
{
} }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* *
* @param int $id * @param \App\Models\Faqs\Faq $faq
* @param \App\Http\Requests\Backend\Faqs\EditFaqsRequest $request
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function edit(Faq $faq, EditFaqsRequest $request) public function edit(Faq $faq, EditFaqsRequest $request)
{ {
return view('backend.faqs.edit')->withItem($faq); return view('backend.faqs.edit')
->with('faq', $faq);
} }
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.
* *
* @param \Illuminate\Http\Request $request * @param \App\Http\Requests\Backend\Faqs\UpdateFaqsRequest $request
* @param int $id * @param \App\Models\Faqs\Faq $id
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
...@@ -101,37 +92,27 @@ class FaqsController extends Controller ...@@ -101,37 +92,27 @@ class FaqsController extends Controller
{ {
$input = $request->all(); $input = $request->all();
$this->faqs->update($faq, $input); $this->faq->update($faq, $input);
return redirect()->route('admin.faqs.index')->withFlashSuccess(trans('alerts.backend.faqs.updated')); return redirect()
->route('admin.faqs.index')
->with('flash_success', trans('alerts.backend.faqs.updated'));
} }
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param int $id * @param \App\Models\Faqs\Faq $faq
* @param \App\Http\Requests\Backend\Faqs\DeleteFaqsRequest $request
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function destroy(Faq $faq, DeleteFaqsRequest $request) public function destroy(Faq $faq, DeleteFaqsRequest $request)
{ {
$this->faqs->delete($faq); $this->faq->delete($faq);
return redirect()->route('admin.faqs.index')->withFlashSuccess(trans('alerts.backend.faqs.deleted'));
}
/**
* @param Faq $Faq
* @param $status
* @param ManageFaqRequest $request
*
* @return mixed
*/
public function mark($id, $status, EditFaqsRequest $request)
{
$faq = Faq::find($id);
$this->faqs->mark($faq, $status);
return redirect()->route('admin.faqs.index')->withFlashSuccess(trans('alerts.backend.faqs.updated')); return redirect()
->route('admin.faqs.index')
->with('flash_success', trans('alerts.backend.faqs.deleted'));
} }
} }
<?php
namespace App\Http\Controllers\Backend\Menu;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Menu\CreateMenuRequest;
use App\Http\Requests\Backend\Menu\DeleteMenuRequest;
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\Models\Menu\Menu;
use App\Repositories\Backend\Menu\MenuRepository;
use Illuminate\Support\Facades\DB;
class MenuController extends Controller
{
protected $menu;
/**
* @param \App\Repositories\Backend\Menu\MenuRepository $menu
*/
public function __construct(MenuRepository $menu)
{
$this->menu = $menu;
}
/**
* Display a listing of the resource.
*
* @param \App\Http\Requests\Backend\Menu\ManageMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
public function index(ManageMenuRequest $request)
{
return view('backend.menus.index');
}
/**
* Show the form for creating a new resource.
*
* @param \App\Http\Requests\Backend\Menu\CreateMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
public function create(CreateMenuRequest $request)
{
$types = [
'backend' => 'Backend',
'frontend' => 'Frontend',
];
$modules = DB::table('modules')->get();
return view('backend.menus.create')->withTypes($types)->withModules($modules);
}
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\Backend\Menu\StoreMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
public function store(StoreMenuRequest $request)
{
$this->menu->create($request->except('_token'));
return redirect()->route('admin.menus.index')->withFlashSuccess(trans('alerts.backend.menus.created'));
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Menu\Menu $menu
* @param \App\Http\Requests\Backend\Menu\EditMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
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);
}
/**
* Update the specified resource in storage.
*
* @param \App\Models\Menu\Menu $menu
* @param \App\Http\Requests\Backend\Menu\UpdateMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
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'));
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Menu\Menu $menu
* @param \App\Http\Requests\Backend\Menu\DeleteMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
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'));
}
}
<?php
namespace App\Http\Controllers\Backend\Menu;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Menu\CreateMenuRequest;
class MenuFormController extends Controller
{
/**
* Get the form for modal popup.
*
* @param string $formName
* @param \App\Http\Requests\Backend\Menu\CreateMenuRequest
*
* @return \Illuminate\Http\Response
*/
public function create($formName, CreateMenuRequest $request)
{
if (in_array($formName, ['_add_custom_url_form'])) {
return view('backend.menus.'.$formName);
}
return abort(404);
}
}
<?php
namespace App\Http\Controllers\Backend\Menu;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Menu\ManageMenuRequest;
use App\Repositories\Backend\Menu\MenuRepository;
use Carbon\Carbon;
use Yajra\DataTables\Facades\DataTables;
/**
* Class MenuTableController.
*/
class MenuTableController extends Controller
{
protected $menus;
/**
* @param \App\Repositories\Backend\Menu\MenuRepository $menus
*/
public function __construct(MenuRepository $menus)
{
$this->menus = $menus;
}
/**
* @param \App\Http\Requests\Backend\Menu\ManageMenuRequest $request
*
* @return mixed
*/
public function __invoke(ManageMenuRequest $request)
{
return Datatables::of($this->menus->getForDataTable())
->escapeColumns(['name'])
->addColumn('type', function ($menus) {
return ucwords($menus->type);
})
->addColumn('created_at', function ($menus) {
return Carbon::parse($menus->created_at)->toDateTimeString();
})
->addColumn('updated_at', function ($menus) {
return Carbon::parse($menus->updated_at)->toDateTimeString();
})
->addColumn('actions', function ($menus) {
return $menus->action_buttons;
})
->make(true);
}
}
...@@ -17,9 +17,6 @@ use App\Repositories\Backend\Pages\PagesRepository; ...@@ -17,9 +17,6 @@ use App\Repositories\Backend\Pages\PagesRepository;
*/ */
class PagesController extends Controller class PagesController extends Controller
{ {
/**
* @var PagesRepository
*/
protected $pages; protected $pages;
/** /**
......
...@@ -5,7 +5,6 @@ namespace App\Http\Controllers\Backend\Pages; ...@@ -5,7 +5,6 @@ namespace App\Http\Controllers\Backend\Pages;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Pages\ManagePageRequest; use App\Http\Requests\Backend\Pages\ManagePageRequest;
use App\Repositories\Backend\Pages\PagesRepository; use App\Repositories\Backend\Pages\PagesRepository;
use Carbon\Carbon;
use Yajra\DataTables\Facades\DataTables; use Yajra\DataTables\Facades\DataTables;
/** /**
...@@ -13,9 +12,6 @@ use Yajra\DataTables\Facades\DataTables; ...@@ -13,9 +12,6 @@ use Yajra\DataTables\Facades\DataTables;
*/ */
class PagesTableController extends Controller class PagesTableController extends Controller
{ {
/**
* @var PagesRepository
*/
protected $pages; protected $pages;
/** /**
...@@ -35,17 +31,17 @@ class PagesTableController extends Controller ...@@ -35,17 +31,17 @@ class PagesTableController extends Controller
{ {
return Datatables::of($this->pages->getForDataTable()) return Datatables::of($this->pages->getForDataTable())
->escapeColumns(['title']) ->escapeColumns(['title'])
->addColumn('status', function ($pages) { ->addColumn('status', function ($page) {
return $pages->status_label; return $page->status_label;
}) })
->addColumn('created_at', function ($pages) { ->addColumn('created_at', function ($page) {
return Carbon::parse($pages->created_at)->toDateString(); return $page->created_at->toDateString();
}) })
->addColumn('updated_at', function ($pages) { ->addColumn('created_by', function ($page) {
return Carbon::parse($pages->updated_at)->toDateString(); return $page->created_by;
}) })
->addColumn('actions', function ($pages) { ->addColumn('actions', function ($page) {
return $pages->action_buttons; return $page->action_buttons;
}) })
->make(true); ->make(true);
} }
......
...@@ -7,20 +7,16 @@ use App\Http\Requests\Backend\Settings\ManageSettingsRequest; ...@@ -7,20 +7,16 @@ use App\Http\Requests\Backend\Settings\ManageSettingsRequest;
use App\Http\Requests\Backend\Settings\UpdateSettingsRequest; use App\Http\Requests\Backend\Settings\UpdateSettingsRequest;
use App\Models\Settings\Setting; use App\Models\Settings\Setting;
use App\Repositories\Backend\Settings\SettingsRepository; use App\Repositories\Backend\Settings\SettingsRepository;
use Illuminate\Http\Request;
/** /**
* Class SettingsController. * Class SettingsController.
*/ */
class SettingsController extends Controller class SettingsController extends Controller
{ {
/**
* @var SettingsRepository
*/
protected $settings; protected $settings;
/** /**
* @param SettingsRepository $settings * @param \App\Repositories\Backend\Settings\SettingsRepository $settings
*/ */
public function __construct(SettingsRepository $settings) public function __construct(SettingsRepository $settings)
{ {
...@@ -28,8 +24,8 @@ class SettingsController extends Controller ...@@ -28,8 +24,8 @@ class SettingsController extends Controller
} }
/** /**
* @param Setting $setting * @param \App\Models\Settings\Setting $setting
* @param ManageEmailTemplatesRequest $request * @param \App\Http\Requests\Backend\Settings\ManageSettingsRequest $request
* *
* @return mixed * @return mixed
*/ */
...@@ -40,33 +36,17 @@ class SettingsController extends Controller ...@@ -40,33 +36,17 @@ class SettingsController extends Controller
} }
/** /**
* @param Setting $setting * @param \App\Models\Settings\Setting $setting
* @param UpdateEmailTemplatesRequest $request * @param \App\Http\Requests\Backend\Settings\UpdateSettingsRequest $request
* *
* @return mixed * @return mixed
*/ */
public function update(Setting $setting, UpdateSettingsRequest $request) public function update(Setting $setting, UpdateSettingsRequest $request)
{ {
$this->settings->update($setting, $request->all()); $this->settings->update($setting, $request->except(['_token', '_method']));
return redirect()->route('admin.settings.edit', $setting->id)->withFlashSuccess(trans('alerts.backend.settings.updated'));
}
/**
* @param Setting $setting
* @param Request $request
* Remove logo or favicon icon
*
* @return mixed
*/
public function removeIcon(Request $request)
{
$this->settings->removeicon($request->data);
return json_encode( return redirect()
[ ->route('admin.settings.edit', $setting->id)
'status' => true, ->with('flash_success', trans('alerts.backend.settings.updated'));
]
);
} }
} }
<?php
namespace App\Http\Controllers\Backend\Settings;
use App\Http\Controllers\Controller;
use App\Models\Settings\Setting;
use App\Repositories\Backend\Settings\SettingsRepository;
use Illuminate\Http\Request;
/**
* Class SettingsLogoController.
*/
class SettingsLogoController extends Controller
{
protected $settings;
/**
* @param \App\Repositories\Backend\Settings\SettingsRepository $settings
*/
public function __construct(SettingsRepository $settings)
{
$this->settings = $settings;
}
/**
* Remove logo or favicon icon.
*
* @param \App\Models\Settings\Setting $setting
* @param \Illuminate\Http\Request $request
*
* @return mixed
*/
public function destroy(Setting $setting, Request $request)
{
$this->settings->removeLogo($setting, $request->data);
return json_encode([
'status' => true,
]);
}
}
...@@ -50,7 +50,7 @@ class RegisterController extends Controller ...@@ -50,7 +50,7 @@ class RegisterController extends Controller
*/ */
public function register(RegisterRequest $request) public function register(RegisterRequest $request)
{ {
if (config('access.users.confirm_email')) { /*if (config('access.users.confirm_email')) {
$user = $this->user->create($request->all()); $user = $this->user->create($request->all());
event(new UserRegistered($user)); event(new UserRegistered($user));
...@@ -59,6 +59,22 @@ class RegisterController extends Controller ...@@ -59,6 +59,22 @@ class RegisterController extends Controller
access()->login($this->user->create($request->all())); access()->login($this->user->create($request->all()));
event(new UserRegistered(access()->user())); event(new UserRegistered(access()->user()));
return redirect($this->redirectPath());
}*/
if (config('access.users.confirm_email') || config('access.users.requires_approval')) {
$user = $this->user->create($request->only('first_name', 'last_name', 'email', 'password', 'is_term_accept'));
event(new UserRegistered($user));
return redirect($this->redirectPath())->withFlashSuccess(
config('access.users.requires_approval') ?
trans('exceptions.frontend.auth.confirmation.created_pending') :
trans('exceptions.frontend.auth.confirmation.created_confirm')
);
} else {
access()->login($this->user->create($request->only('first_name', 'last_name', 'email', 'password', 'is_term_accept')));
event(new UserRegistered(access()->user()));
return redirect($this->redirectPath()); return redirect($this->redirectPath());
} }
} }
......
...@@ -50,9 +50,20 @@ class ResetPasswordController extends Controller ...@@ -50,9 +50,20 @@ class ResetPasswordController extends Controller
*/ */
public function showResetForm($token = null) public function showResetForm($token = null)
{ {
if (!$token) {
return redirect()->route('frontend.auth.password.email');
}
$user = $this->user->findByPasswordResetToken($token);
if ($user && app()->make('auth.password.broker')->tokenExists($user, $token)) {
return view('frontend.auth.passwords.reset') return view('frontend.auth.passwords.reset')
->withToken($token) ->withToken($token)
->withEmail($this->user->getEmailForPasswordToken($token)); ->withEmail($user->email);
}
return redirect()->route('frontend.auth.password.email')
->withFlashDanger(trans('exceptions.frontend.auth.password.reset_problem'));
} }
/** /**
...@@ -80,4 +91,16 @@ class ResetPasswordController extends Controller ...@@ -80,4 +91,16 @@ class ResetPasswordController extends Controller
'password.regex' => 'Password must contain at least 1 uppercase letter and 1 number.', 'password.regex' => 'Password must contain at least 1 uppercase letter and 1 number.',
]; ];
} }
/**
* Get the response for a successful password reset.
*
* @param string $response
*
* @return \Illuminate\Http\RedirectResponse
*/
protected function sendResetResponse($response)
{
return redirect()->route(homeRoute())->withFlashSuccess(trans($response));
}
} }
...@@ -26,8 +26,22 @@ class StoreRoleRequest extends Request ...@@ -26,8 +26,22 @@ class StoreRoleRequest extends Request
*/ */
public function rules() public function rules()
{ {
$permissions = '';
if ($this->associated_permissions != 'all') {
$permissions = 'required';
}
return [ return [
'name' => 'required|max:191', 'name' => 'required|max:191',
'permissions' => $permissions,
];
}
public function messages()
{
return [
'permissions.required' => 'You must select at least one permission for this role.',
]; ];
} }
} }
...@@ -26,8 +26,22 @@ class UpdateRoleRequest extends Request ...@@ -26,8 +26,22 @@ class UpdateRoleRequest extends Request
*/ */
public function rules() public function rules()
{ {
$permissions = '';
if ($this->associated_permissions != 'all') {
$permissions = 'required';
}
return [ return [
'name' => 'required|max:191', 'name' => 'required|max:191',
'permissions' => $permissions,
];
}
public function messages()
{
return [
'permissions.required' => 'You must select at least one permission for this role.',
]; ];
} }
} }
...@@ -32,6 +32,8 @@ class StoreUserRequest extends Request ...@@ -32,6 +32,8 @@ class StoreUserRequest extends Request
'last_name' => 'required|max:255', 'last_name' => 'required|max:255',
'email' => ['required', 'email', 'max:255', Rule::unique('users')], 'email' => ['required', 'email', 'max:255', Rule::unique('users')],
'password' => 'required|min:6|confirmed', 'password' => 'required|min:6|confirmed',
'assignees_roles' => 'required',
'permissions' => 'required',
]; ];
} }
...@@ -43,6 +45,7 @@ class StoreUserRequest extends Request ...@@ -43,6 +45,7 @@ class StoreUserRequest extends Request
public function messages() public function messages()
{ {
return [ return [
'assignees_roles' => 'Please Select Role',
]; ];
} }
} }
...@@ -30,6 +30,8 @@ class UpdateUserRequest extends Request ...@@ -30,6 +30,8 @@ class UpdateUserRequest extends Request
'email' => 'required|email', 'email' => 'required|email',
'first_name' => 'required', 'first_name' => 'required',
'last_name' => 'required', 'last_name' => 'required',
'permissions' => 'required',
'assignees_roles' => 'required',
]; ];
} }
...@@ -41,6 +43,7 @@ class UpdateUserRequest extends Request ...@@ -41,6 +43,7 @@ class UpdateUserRequest extends Request
public function messages() public function messages()
{ {
return [ return [
'assignees_roles' => 'Please Select Role',
]; ];
} }
} }
...@@ -39,7 +39,7 @@ class StoreBlogTagsRequest extends Request ...@@ -39,7 +39,7 @@ class StoreBlogTagsRequest extends Request
public function messages() public function messages()
{ {
return [ return [
'name.required' => 'Blog Tag name must required', 'name.required' => 'Blog Tag name is a required field.',
'name.max' => 'Blog Tag may not be greater than 191 characters.', 'name.max' => 'Blog Tag may not be greater than 191 characters.',
]; ];
} }
......
...@@ -39,7 +39,7 @@ class UpdateBlogTagsRequest extends Request ...@@ -39,7 +39,7 @@ class UpdateBlogTagsRequest extends Request
public function messages() public function messages()
{ {
return [ return [
'name.required' => 'Blog Tag name must required', 'name.required' => 'Blog Tag name is a required field.',
'name.max' => 'Blog Tag may not be greater than 191 characters.', 'name.max' => 'Blog Tag may not be greater than 191 characters.',
]; ];
} }
......
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class CreateMenuRequest.
*/
class CreateMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('create-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class DeleteMenuRequest.
*/
class DeleteMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('delete-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class EditMenuRequest.
*/
class EditMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('edit-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class ManageMenuRequest.
*/
class ManageMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('view-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class StoreMenuRequest.
*/
class StoreMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('create-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
'type' => 'required',
];
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class UpdateMenuRequest.
*/
class UpdateMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('edit-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
'type' => 'required',
];
}
}
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace App\Http\Requests\Backend\Settings; namespace App\Http\Requests\Backend\Settings;
use App\Http\Requests\Request; use App\Http\Requests\Request;
use App\Models\Settings\Setting;
/** /**
* Class UpdateSettingsRequest. * Class UpdateSettingsRequest.
...@@ -27,25 +26,9 @@ class UpdateSettingsRequest extends Request ...@@ -27,25 +26,9 @@ class UpdateSettingsRequest extends Request
*/ */
public function rules() public function rules()
{ {
$data = Setting::find(1);
$checkLogo = $data->logo;
$checkFavicon = $data->favicon;
if (!empty($checkLogo)) {
$logoValidation = 'image|dimensions:min_width=226,min_height=48';
} else {
$logoValidation = 'required|image|dimensions:min_width=226,min_height=48';
}
if (!empty($checkFavicon)) {
$faviconValidation = 'mimes:jpg,jpeg,png,ico|dimensions:width=16,height=16';
} else {
$faviconValidation = 'required|mimes:jpg,jpeg,png,ico|dimensions:width=16,height=16';
}
return [ return [
'logo' => $logoValidation, 'logo' => 'image|dimensions:min_width=226,min_height=48',
'favicon' => $faviconValidation, 'favicon' => 'mimes:jpg,jpeg,png,ico|dimensions:width=16,height=16',
'from_name' => 'required',
'from_email' => 'required',
]; ];
} }
...@@ -58,11 +41,7 @@ class UpdateSettingsRequest extends Request ...@@ -58,11 +41,7 @@ class UpdateSettingsRequest extends Request
{ {
return [ return [
'logo.dimensions' => 'Invalid logo - should be minimum 226*48', 'logo.dimensions' => 'Invalid logo - should be minimum 226*48',
'favicon.dimensions' => 'Invalid icon - should be 16*16', 'favicon.dimensions' => 'Invalid favicon - should be 16*16',
'logo.required' => 'The logo field is required in seo settings.',
'favicon.required' => 'The favicon field is required in seo settings.',
'from_name.required' => 'The from name field is required in mail settings.',
'from_email.required' => 'The from email field is required in mail settings.',
]; ];
} }
} }
...@@ -18,8 +18,8 @@ class BlogCategoryEventListener ...@@ -18,8 +18,8 @@ class BlogCategoryEventListener
public function onCreated($event) public function onCreated($event)
{ {
history()->withType($this->history_slug) history()->withType($this->history_slug)
->withEntity($event->blogcategories->id) ->withEntity($event->blogcategory->id)
->withText('trans("history.backend.blogcategories.created") <strong>'.$event->blogcategories->name.'</strong>') ->withText('trans("history.backend.blogcategories.created") <strong>'.$event->blogcategory->name.'</strong>')
->withIcon('plus') ->withIcon('plus')
->withClass('bg-green') ->withClass('bg-green')
->log(); ->log();
...@@ -31,8 +31,8 @@ class BlogCategoryEventListener ...@@ -31,8 +31,8 @@ class BlogCategoryEventListener
public function onUpdated($event) public function onUpdated($event)
{ {
history()->withType($this->history_slug) history()->withType($this->history_slug)
->withEntity($event->blogcategories->id) ->withEntity($event->blogcategory->id)
->withText('trans("history.backend.blogcategories.updated") <strong>'.$event->blogcategories->name.'</strong>') ->withText('trans("history.backend.blogcategories.updated") <strong>'.$event->blogcategory->name.'</strong>')
->withIcon('save') ->withIcon('save')
->withClass('bg-aqua') ->withClass('bg-aqua')
->log(); ->log();
...@@ -44,8 +44,8 @@ class BlogCategoryEventListener ...@@ -44,8 +44,8 @@ class BlogCategoryEventListener
public function onDeleted($event) public function onDeleted($event)
{ {
history()->withType($this->history_slug) history()->withType($this->history_slug)
->withEntity($event->blogcategories->id) ->withEntity($event->blogcategory->id)
->withText('trans("history.backend.blogcategories.deleted") <strong>'.$event->blogcategories->name.'</strong>') ->withText('trans("history.backend.blogcategories.deleted") <strong>'.$event->blogcategory->name.'</strong>')
->withIcon('trash') ->withIcon('trash')
->withClass('bg-maroon') ->withClass('bg-maroon')
->log(); ->log();
......
...@@ -18,8 +18,8 @@ class BlogTagEventListener ...@@ -18,8 +18,8 @@ class BlogTagEventListener
public function onCreated($event) public function onCreated($event)
{ {
history()->withType($this->history_slug) history()->withType($this->history_slug)
->withEntity($event->blogtags->id) ->withEntity($event->blogtag->id)
->withText('trans("history.backend.blogtags.created") <strong>'.$event->blogtags->name.'</strong>') ->withText('trans("history.backend.blogtags.created") <strong>'.$event->blogtag->name.'</strong>')
->withIcon('plus') ->withIcon('plus')
->withClass('bg-green') ->withClass('bg-green')
->log(); ->log();
...@@ -31,8 +31,8 @@ class BlogTagEventListener ...@@ -31,8 +31,8 @@ class BlogTagEventListener
public function onUpdated($event) public function onUpdated($event)
{ {
history()->withType($this->history_slug) history()->withType($this->history_slug)
->withEntity($event->blogtags->id) ->withEntity($event->blogtag->id)
->withText('trans("history.backend.blogtags.updated") <strong>'.$event->blogtags->name.'</strong>') ->withText('trans("history.backend.blogtags.updated") <strong>'.$event->blogtag->name.'</strong>')
->withIcon('save') ->withIcon('save')
->withClass('bg-aqua') ->withClass('bg-aqua')
->log(); ->log();
...@@ -44,8 +44,8 @@ class BlogTagEventListener ...@@ -44,8 +44,8 @@ class BlogTagEventListener
public function onDeleted($event) public function onDeleted($event)
{ {
history()->withType($this->history_slug) history()->withType($this->history_slug)
->withEntity($event->blogtags->id) ->withEntity($event->blogtag->id)
->withText('trans("history.backend.blogtags.deleted") <strong>'.$event->blogtags->name.'</strong>') ->withText('trans("history.backend.blogtags.deleted") <strong>'.$event->blogtag->name.'</strong>')
->withIcon('trash') ->withIcon('trash')
->withClass('bg-maroon') ->withClass('bg-maroon')
->log(); ->log();
......
...@@ -30,6 +30,14 @@ class UserEventListener ...@@ -30,6 +30,14 @@ class UserEventListener
* @param $event * @param $event
*/ */
public function onRegistered($event) public function onRegistered($event)
{
\Log::info('User Registered: '.$event->user->full_name);
}
/**
* @param $event
*/
/*public function onRegistered($event)
{ {
\Log::info('User Registered: '.$event->user->first_name); \Log::info('User Registered: '.$event->user->first_name);
...@@ -39,7 +47,7 @@ class UserEventListener ...@@ -39,7 +47,7 @@ class UserEventListener
'email_template_type' => 1, 'email_template_type' => 1,
]; ];
createNotification('', 1, 2, $options); createNotification('', 1, 2, $options);
} }*/
/** /**
* @param $event * @param $event
......
...@@ -213,9 +213,9 @@ trait UserAttribute ...@@ -213,9 +213,9 @@ trait UserAttribute
/** /**
* @return string * @return string
*/ */
public function getDeletePermanentlyButtonAttribute() public function getDeletePermanentlyButtonAttribute($class)
{ {
return '<a href="'.route('admin.access.user.delete-permanently', $this).'" name="delete_user_perm"><i class="fa fa-trash" data-toggle="tooltip" data-placement="top" title="'.trans('buttons.backend.access.users.delete_permanently').'"></i></a> '; return '<a class="'.$class.'" href="'.route('admin.access.user.delete-permanently', $this).'" name="delete_user_perm"><i class="fa fa-trash" data-toggle="tooltip" data-placement="top" title="'.trans('buttons.backend.access.users.delete_permanently').'"></i></a> ';
} }
/** /**
...@@ -372,13 +372,21 @@ trait UserAttribute ...@@ -372,13 +372,21 @@ trait UserAttribute
return $button; return $button;
} }
public function getNameAttribute()
{
return $this->first_name.' '.$this->last_name;
}
/** /**
* @return string * @return string
*/ */
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
if ($this->trashed()) { if ($this->trashed()) {
return '<div class="btn-group action-btn">'.$this->getRestoreButtonAttribute('btn btn-default btn-flat').'</div>'; return '<div class="btn-group action-btn">
'.$this->getRestoreButtonAttribute('btn btn-default btn-flat').'
'.$this->getDeletePermanentlyButtonAttribute('btn btn-default btn-flat').'
</div>';
} }
// Check if role have all permission // Check if role have all permission
......
...@@ -29,6 +29,6 @@ class BlogCategory extends BaseModel ...@@ -29,6 +29,6 @@ class BlogCategory extends BaseModel
public function __construct(array $attributes = []) public function __construct(array $attributes = [])
{ {
parent::__construct($attributes); parent::__construct($attributes);
$this->table = config('access.blog_categories_table'); $this->table = config('module.blog_categories.table');
} }
} }
...@@ -13,8 +13,28 @@ trait BlogCategoryAttribute ...@@ -13,8 +13,28 @@ trait BlogCategoryAttribute
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn"> return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute('edit-blog-category', 'admin.blogcategories.edit').' '.$this->getEditButtonAttribute('edit-blog-category', 'admin.blogCategories.edit').'
'.$this->getDeleteButtonAttribute('delete-blog-category', 'admin.blogcategories.destroy').' '.$this->getDeleteButtonAttribute('delete-blog-category', 'admin.blogCategories.destroy').'
</div>'; </div>';
} }
/**
* @return string
*/
public function getStatusLabelAttribute()
{
if ($this->isActive()) {
return "<label class='label label-success'>".trans('labels.general.active').'</label>';
}
return "<label class='label label-danger'>".trans('labels.general.inactive').'</label>';
}
/**
* @return bool
*/
public function isActive()
{
return $this->status == 1;
}
} }
...@@ -12,8 +12,8 @@ trait BlogCategoryRelationship ...@@ -12,8 +12,8 @@ trait BlogCategoryRelationship
/** /**
* BlogCategories belongs to relationship with state. * BlogCategories belongs to relationship with state.
*/ */
public function createdBy() public function creator()
{ {
return $this->belongsTo(User::class, 'created_by', 'id'); return $this->belongsTo(User::class, 'created_by');
} }
} }
...@@ -11,11 +11,10 @@ class BlogMapCategory extends BaseModel ...@@ -11,11 +11,10 @@ class BlogMapCategory extends BaseModel
* *
* @var string * @var string
*/ */
protected $table; protected $table = 'blog_map_categories';
public function __construct(array $attributes = []) public function __construct(array $attributes = [])
{ {
parent::__construct($attributes); parent::__construct($attributes);
$this->table = config('access.blog_map_categories_table');
} }
} }
...@@ -11,11 +11,10 @@ class BlogMapTag extends BaseModel ...@@ -11,11 +11,10 @@ class BlogMapTag extends BaseModel
* *
* @var string * @var string
*/ */
protected $table; protected $table = 'blog_map_tags';
public function __construct(array $attributes = []) public function __construct(array $attributes = [])
{ {
parent::__construct($attributes); parent::__construct($attributes);
$this->table = config('access.blog_map_tags');
} }
} }
...@@ -29,6 +29,6 @@ class BlogTag extends BaseModel ...@@ -29,6 +29,6 @@ class BlogTag extends BaseModel
public function __construct(array $attributes = []) public function __construct(array $attributes = [])
{ {
parent::__construct($attributes); parent::__construct($attributes);
$this->table = config('access.blog_tags_table'); $this->table = config('module.blog_tags.table');
} }
} }
...@@ -13,8 +13,28 @@ trait BlogTagAttribute ...@@ -13,8 +13,28 @@ trait BlogTagAttribute
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn"> return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute('edit-blog-tag', 'admin.blogtags.edit').' '.$this->getEditButtonAttribute('edit-blog-tag', 'admin.blogTags.edit').'
'.$this->getDeleteButtonAttribute('delete-blog-tag', 'admin.blogtags.destroy').' '.$this->getDeleteButtonAttribute('delete-blog-tag', 'admin.blogTags.destroy').'
</div>'; </div>';
} }
/**
* @return string
*/
public function getStatusLabelAttribute()
{
if ($this->isActive()) {
return "<label class='label label-success'>".trans('labels.general.active').'</label>';
}
return "<label class='label label-danger'>".trans('labels.general.inactive').'</label>';
}
/**
* @return bool
*/
public function isActive()
{
return $this->status == 1;
}
} }
...@@ -12,8 +12,8 @@ trait BlogTagRelationship ...@@ -12,8 +12,8 @@ trait BlogTagRelationship
/** /**
* BlogTags belongs to relationship with state. * BlogTags belongs to relationship with state.
*/ */
public function createdBy() public function creator()
{ {
return $this->belongsTo(User::class, 'created_by', 'id'); return $this->belongsTo(User::class, 'created_by');
} }
} }
...@@ -17,6 +17,26 @@ class Blog extends BaseModel ...@@ -17,6 +17,26 @@ class Blog extends BaseModel
// BlogAttribute::getEditButtonAttribute insteadof ModelTrait; // BlogAttribute::getEditButtonAttribute insteadof ModelTrait;
} }
protected $fillable = [
'name',
'slug',
'publish_datetime',
'content',
'meta_title',
'cannonical_link',
'meta_keywords',
'meta_description',
'status',
'featured_image',
'created_by',
];
protected $dates = [
'publish_datetime',
'created_at',
'updated_at',
];
/** /**
* The database table used by the model. * The database table used by the model.
* *
...@@ -27,6 +47,6 @@ class Blog extends BaseModel ...@@ -27,6 +47,6 @@ class Blog extends BaseModel
public function __construct(array $attributes = []) public function __construct(array $attributes = [])
{ {
parent::__construct($attributes); parent::__construct($attributes);
$this->table = config('access.blogs_table'); $this->table = config('module.blogs.table');
} }
} }
...@@ -30,8 +30,8 @@ trait BlogRelationship ...@@ -30,8 +30,8 @@ trait BlogRelationship
/** /**
* Blogs belongsTo with User. * Blogs belongsTo with User.
*/ */
public function createdBy() public function owner()
{ {
return $this->belongsTo(User::class, 'created_by', 'id'); return $this->belongsTo(User::class, 'created_by');
} }
} }
...@@ -32,6 +32,6 @@ class Faq extends BaseModel ...@@ -32,6 +32,6 @@ class Faq extends BaseModel
public function __construct(array $attributes = []) public function __construct(array $attributes = [])
{ {
parent::__construct($attributes); parent::__construct($attributes);
$this->table = config('access.faqs_table'); $this->table = config('module.faqs.table');
} }
} }
<?php
namespace App\Models\Menu;
use App\Models\Menu\Traits\Attribute\MenuAttribute;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Menu extends Model
{
use ModelTrait,
MenuAttribute,
SoftDeletes{
// MenuAttribute::getEditButtonAttribute insteadof ModelTrait;
}
/**
* The database table used by the model.
*
* @var string
*/
protected $table;
protected $fillable = [
'name',
'type',
'items',
];
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->table = config('access.menus_table');
}
}
<?php
namespace App\Models\Menu\Traits\Attribute;
/**
* Class MenuAttribute.
*/
trait MenuAttribute
{
/**
* @return string
*/
public function getActionButtonsAttribute()
{
return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute('edit-menu', 'admin.menus.edit').'
'.$this->getDeleteButtonAttribute('delete-menu', 'admin.menus.destroy').'
</div>';
}
}
...@@ -5,12 +5,14 @@ namespace App\Models\Page; ...@@ -5,12 +5,14 @@ namespace App\Models\Page;
use App\Models\BaseModel; use App\Models\BaseModel;
use App\Models\ModelTrait; use App\Models\ModelTrait;
use App\Models\Page\Traits\Attribute\PageAttribute; use App\Models\Page\Traits\Attribute\PageAttribute;
use App\Models\Page\Traits\PageRelationship;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
class Page extends BaseModel class Page extends BaseModel
{ {
use ModelTrait, use ModelTrait,
SoftDeletes, SoftDeletes,
PageRelationship,
PageAttribute { PageAttribute {
// PageAttribute::getEditButtonAttribute insteadof ModelTrait; // PageAttribute::getEditButtonAttribute insteadof ModelTrait;
} }
...@@ -29,6 +31,17 @@ class Page extends BaseModel ...@@ -29,6 +31,17 @@ class Page extends BaseModel
*/ */
protected $guarded = ['id']; protected $guarded = ['id'];
/**
* The default values for attributes.
*
* @var array
*/
protected $attributes = [
'created_by' => 1,
];
protected $with = ['owner'];
public function __construct(array $attributes = []) public function __construct(array $attributes = [])
{ {
parent::__construct($attributes); parent::__construct($attributes);
......
...@@ -13,8 +13,8 @@ trait PageAttribute ...@@ -13,8 +13,8 @@ trait PageAttribute
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn"> return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute('edit-cms-pages', 'admin.pages.edit').' '.$this->getEditButtonAttribute('edit-page', 'admin.pages.edit').'
'.$this->getDeleteButtonAttribute('delete-cms-pages', 'admin.pages.destroy').' '.$this->getDeleteButtonAttribute('delete-page', 'admin.pages.destroy').'
</div>'; </div>';
} }
......
<?php
namespace App\Models\Page\Traits;
use App\Models\Access\User\User;
trait PageRelationship
{
public function owner()
{
return $this->belongsTo(User::class, 'created_by');
}
}
...@@ -74,7 +74,7 @@ class PermissionRepository extends BaseRepository ...@@ -74,7 +74,7 @@ class PermissionRepository extends BaseRepository
* *
* @return bool * @return bool
*/ */
public function update(Model $permission, array $input) public function update($permission, array $input)
{ {
if ($this->query()->where('name', $input['name'])->where('id', '!=', $permission->id)->first()) { if ($this->query()->where('name', $input['name'])->where('id', '!=', $permission->id)->first()) {
throw new GeneralException(trans('exceptions.backend.access.permissions.already_exists')); throw new GeneralException(trans('exceptions.backend.access.permissions.already_exists'));
...@@ -104,7 +104,7 @@ class PermissionRepository extends BaseRepository ...@@ -104,7 +104,7 @@ class PermissionRepository extends BaseRepository
* *
* @return bool * @return bool
*/ */
public function delete(Model $permission) public function delete($permission)
{ {
DB::transaction(function () use ($permission) { DB::transaction(function () use ($permission) {
if ($permission->delete()) { if ($permission->delete()) {
......
...@@ -69,7 +69,7 @@ class RoleRepository extends BaseRepository ...@@ -69,7 +69,7 @@ class RoleRepository extends BaseRepository
} }
//See if the role has all access //See if the role has all access
$all = $input['associated-permissions'] == 'all' ? true : false; $all = $input['associated_permissions'] == 'all' ? true : false;
if (!isset($input['permissions'])) { if (!isset($input['permissions'])) {
$input['permissions'] = []; $input['permissions'] = [];
...@@ -127,13 +127,13 @@ class RoleRepository extends BaseRepository ...@@ -127,13 +127,13 @@ class RoleRepository extends BaseRepository
* *
* @return bool * @return bool
*/ */
public function update(Model $role, array $input) public function update($role, array $input)
{ {
//See if the role has all access, administrator always has all access //See if the role has all access, administrator always has all access
if ($role->id == 1) { if ($role->id == 1) {
$all = true; $all = true;
} else { } else {
$all = $input['associated-permissions'] == 'all' ? true : false; $all = $input['associated_permissions'] == 'all' ? true : false;
} }
if (!isset($input['permissions'])) { if (!isset($input['permissions'])) {
...@@ -190,13 +190,13 @@ class RoleRepository extends BaseRepository ...@@ -190,13 +190,13 @@ class RoleRepository extends BaseRepository
} }
/** /**
* @param Model $role * @param Role $role
* *
* @throws GeneralException * @throws GeneralException
* *
* @return bool * @return bool
*/ */
public function delete(Model $role) public function delete(Role $role)
{ {
//Would be stupid to delete the administrator role //Would be stupid to delete the administrator role
if ($role->id == 1) { //id is 1 because of the seeder if ($role->id == 1) { //id is 1 because of the seeder
......
...@@ -12,6 +12,7 @@ use App\Events\Backend\Access\User\UserRestored; ...@@ -12,6 +12,7 @@ use App\Events\Backend\Access\User\UserRestored;
use App\Events\Backend\Access\User\UserUpdated; use App\Events\Backend\Access\User\UserUpdated;
use App\Exceptions\GeneralException; use App\Exceptions\GeneralException;
use App\Models\Access\User\User; use App\Models\Access\User\User;
use App\Notifications\Frontend\Auth\UserNeedsConfirmation;
use App\Repositories\Backend\Access\Role\RoleRepository; use App\Repositories\Backend\Access\Role\RoleRepository;
use App\Repositories\BaseRepository; use App\Repositories\BaseRepository;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
...@@ -96,9 +97,6 @@ class UserRepository extends BaseRepository ...@@ -96,9 +97,6 @@ class UserRepository extends BaseRepository
$user = $this->createUserStub($data); $user = $this->createUserStub($data);
DB::transaction(function () use ($user, $data, $roles, $permissions) { DB::transaction(function () use ($user, $data, $roles, $permissions) {
// Set email type 2
$email_type = 2;
if ($user->save()) { if ($user->save()) {
//User Created, Validate Roles //User Created, Validate Roles
...@@ -162,28 +160,23 @@ class UserRepository extends BaseRepository ...@@ -162,28 +160,23 @@ class UserRepository extends BaseRepository
} }
/** /**
* @param Model $user * Change Password.
*
* @param $user
* @param $input * @param $input
* *
* @throws GeneralException * @throws GeneralException
* *
* @return bool * @return bool
*/ */
public function updatePassword(Model $user, $input) public function updatePassword($user, $input)
{ {
$user = $this->find(access()->id()); $user = $this->find(access()->id());
if (Hash::check($input['old_password'], $user->password)) { if (Hash::check($input['old_password'], $user->password)) {
$user->password = bcrypt($input['password']); $user->password = bcrypt($input['password']);
if ($user->save()) {
$input['email'] = $user->email;
// Send email to the user
$options = [
'data' => $input,
'email_template_type' => 4,
];
createNotification('', $user->id, 2, $options);
if ($user->save()) {
event(new UserPasswordChanged($user)); event(new UserPasswordChanged($user));
return true; return true;
...@@ -202,7 +195,7 @@ class UserRepository extends BaseRepository ...@@ -202,7 +195,7 @@ class UserRepository extends BaseRepository
* *
* @return bool * @return bool
*/ */
public function delete(Model $user) public function delete($user)
{ {
if (access()->id() == $user->id) { if (access()->id() == $user->id) {
throw new GeneralException(trans('exceptions.backend.access.users.cant_delete_self')); throw new GeneralException(trans('exceptions.backend.access.users.cant_delete_self'));
...@@ -218,11 +211,11 @@ class UserRepository extends BaseRepository ...@@ -218,11 +211,11 @@ class UserRepository extends BaseRepository
} }
/** /**
* @param Model $user * @param $user
* *
* @throws GeneralException * @throws GeneralException
*/ */
public function forceDelete(Model $user) public function forceDelete($user)
{ {
if (is_null($user->deleted_at)) { if (is_null($user->deleted_at)) {
throw new GeneralException(trans('exceptions.backend.access.users.delete_first')); throw new GeneralException(trans('exceptions.backend.access.users.delete_first'));
...@@ -240,13 +233,13 @@ class UserRepository extends BaseRepository ...@@ -240,13 +233,13 @@ class UserRepository extends BaseRepository
} }
/** /**
* @param Model $user * @param $user
* *
* @throws GeneralException * @throws GeneralException
* *
* @return bool * @return bool
*/ */
public function restore(Model $user) public function restore($user)
{ {
if (is_null($user->deleted_at)) { if (is_null($user->deleted_at)) {
throw new GeneralException(trans('exceptions.backend.access.users.cant_restore')); throw new GeneralException(trans('exceptions.backend.access.users.cant_restore'));
...@@ -262,14 +255,14 @@ class UserRepository extends BaseRepository ...@@ -262,14 +255,14 @@ class UserRepository extends BaseRepository
} }
/** /**
* @param Model $user * @param $user
* @param $status * @param $status
* *
* @throws GeneralException * @throws GeneralException
* *
* @return bool * @return bool
*/ */
public function mark(Model $user, $status) public function mark($user, $status)
{ {
if (access()->id() == $user->id && $status == 0) { if (access()->id() == $user->id && $status == 0) {
throw new GeneralException(trans('exceptions.backend.access.users.cant_deactivate_self')); throw new GeneralException(trans('exceptions.backend.access.users.cant_deactivate_self'));
...@@ -288,13 +281,6 @@ class UserRepository extends BaseRepository ...@@ -288,13 +281,6 @@ class UserRepository extends BaseRepository
} }
if ($user->save()) { if ($user->save()) {
// Send email to the user
$options = [
'data' => $user,
'email_template_type' => 3,
];
createNotification('', $user->id, 2, $options);
return true; return true;
} }
...@@ -339,8 +325,8 @@ class UserRepository extends BaseRepository ...@@ -339,8 +325,8 @@ class UserRepository extends BaseRepository
*/ */
protected function flushPermissions($permissions, $user) protected function flushPermissions($permissions, $user)
{ {
//Flush roles out, then add array of new ones //Flush permission out, then add array of new ones
$user->detachPermissions($user->roles); $user->detachPermissions($user->permissions);
$user->attachPermissions($permissions); $user->attachPermissions($permissions);
} }
......
...@@ -26,13 +26,13 @@ class BlogCategoriesRepository extends BaseRepository ...@@ -26,13 +26,13 @@ class BlogCategoriesRepository extends BaseRepository
public function getForDataTable() public function getForDataTable()
{ {
return $this->query() return $this->query()
->leftjoin(config('access.users_table'), config('access.users_table').'.id', '=', config('access.blog_categories_table').'.created_by') ->leftjoin(config('access.users_table'), config('access.users_table').'.id', '=', config('module.blog_categories.table').'.created_by')
->select([ ->select([
config('access.blog_categories_table').'.id', config('module.blog_categories.table').'.id',
config('access.blog_categories_table').'.name', config('module.blog_categories.table').'.name',
config('access.blog_categories_table').'.status', config('module.blog_categories.table').'.status',
config('access.blog_categories_table').'.created_by', config('module.blog_categories.table').'.created_by',
config('access.blog_categories_table').'.created_at', config('module.blog_categories.table').'.created_at',
config('access.users_table').'.first_name as user_name', config('access.users_table').'.first_name as user_name',
]); ]);
} }
...@@ -40,7 +40,7 @@ class BlogCategoriesRepository extends BaseRepository ...@@ -40,7 +40,7 @@ class BlogCategoriesRepository extends BaseRepository
/** /**
* @param array $input * @param array $input
* *
* @throws GeneralException * @throws \App\Exceptions\GeneralException
* *
* @return bool * @return bool
*/ */
...@@ -49,16 +49,13 @@ class BlogCategoriesRepository extends BaseRepository ...@@ -49,16 +49,13 @@ class BlogCategoriesRepository extends BaseRepository
if ($this->query()->where('name', $input['name'])->first()) { if ($this->query()->where('name', $input['name'])->first()) {
throw new GeneralException(trans('exceptions.backend.blogcategories.already_exists')); throw new GeneralException(trans('exceptions.backend.blogcategories.already_exists'));
} }
DB::transaction(function () use ($input) { DB::transaction(function () use ($input) {
$blogcategories = self::MODEL; $input['status'] = isset($input['status']) ? 1 : 0;
$blogcategories = new $blogcategories(); $input['created_by'] = access()->user()->id;
$blogcategories->name = $input['name'];
$blogcategories->status = (isset($input['status']) && $input['status'] == 1)
? 1 : 0;
$blogcategories->created_by = access()->user()->id;
if ($blogcategories->save()) { if ($blogcategory = BlogCategory::create($input)) {
event(new BlogCategoryCreated($blogcategories)); event(new BlogCategoryCreated($blogcategory));
return true; return true;
} }
...@@ -68,44 +65,41 @@ class BlogCategoriesRepository extends BaseRepository ...@@ -68,44 +65,41 @@ class BlogCategoriesRepository extends BaseRepository
} }
/** /**
* @param Model $permission * @param \App\Models\BlogCategories\BlogCategory $blogcategory
* @param $input * @param $input
* *
* @throws GeneralException * @throws \App\Exceptions\GeneralException
* *
* return bool * return bool
*/ */
public function update(Model $blogcategories, array $input) public function update(BlogCategory $blogcategory, array $input)
{ {
if ($this->query()->where('name', $input['name'])->where('id', '!=', $blogcategories->id)->first()) { if ($this->query()->where('name', $input['name'])->where('id', '!=', $blogcategory->id)->first()) {
throw new GeneralException(trans('exceptions.backend.blogcategories.already_exists')); throw new GeneralException(trans('exceptions.backend.blogcategories.already_exists'));
} }
$blogcategories->name = $input['name'];
$blogcategories->status = (isset($input['status']) && $input['status'] == 1)
? 1 : 0;
$blogcategories->updated_by = access()->user()->id;
DB::transaction(function () use ($blogcategories, $input) { DB::transaction(function () use ($blogcategory, $input) {
if ($blogcategories->save()) { $input['status'] = isset($input['status']) ? 1 : 0;
event(new BlogCategoryUpdated($blogcategories)); $input['updated_by'] = access()->user()->id;
if ($blogcategory->update($input)) {
event(new BlogCategoryUpdated($blogcategory));
return true; return true;
} }
throw new GeneralException( throw new GeneralException(trans('exceptions.backend.blogcategories.update_error'));
trans('exceptions.backend.blogcategories.update_error')
);
}); });
} }
/** /**
* @param Model $blogcategory * @param \App\Models\BlogCategories\BlogCategory $blogcategory
* *
* @throws GeneralException * @throws \App\Exceptions\GeneralException
* *
* @return bool * @return bool
*/ */
public function delete(Model $blogcategory) public function delete(BlogCategory $blogcategory)
{ {
DB::transaction(function () use ($blogcategory) { DB::transaction(function () use ($blogcategory) {
if ($blogcategory->delete()) { if ($blogcategory->delete()) {
......
...@@ -26,13 +26,13 @@ class BlogTagsRepository extends BaseRepository ...@@ -26,13 +26,13 @@ class BlogTagsRepository extends BaseRepository
public function getForDataTable() public function getForDataTable()
{ {
return $this->query() return $this->query()
->leftjoin(config('access.users_table'), config('access.users_table').'.id', '=', config('access.blog_tags_table').'.created_by') ->leftjoin(config('access.users_table'), config('access.users_table').'.id', '=', config('module.blog_tags.table').'.created_by')
->select([ ->select([
config('access.blog_tags_table').'.id', config('module.blog_tags.table').'.id',
config('access.blog_tags_table').'.name', config('module.blog_tags.table').'.name',
config('access.blog_tags_table').'.status', config('module.blog_tags.table').'.status',
config('access.blog_tags_table').'.created_by', config('module.blog_tags.table').'.created_by',
config('access.blog_tags_table').'.created_at', config('module.blog_tags.table').'.created_at',
config('access.users_table').'.first_name as user_name', config('access.users_table').'.first_name as user_name',
]); ]);
} }
...@@ -40,7 +40,7 @@ class BlogTagsRepository extends BaseRepository ...@@ -40,7 +40,7 @@ class BlogTagsRepository extends BaseRepository
/** /**
* @param array $input * @param array $input
* *
* @throws GeneralException * @throws \App\Exceptions\GeneralException
* *
* @return bool * @return bool
*/ */
...@@ -49,16 +49,13 @@ class BlogTagsRepository extends BaseRepository ...@@ -49,16 +49,13 @@ class BlogTagsRepository extends BaseRepository
if ($this->query()->where('name', $input['name'])->first()) { if ($this->query()->where('name', $input['name'])->first()) {
throw new GeneralException(trans('exceptions.backend.blogtags.already_exists')); throw new GeneralException(trans('exceptions.backend.blogtags.already_exists'));
} }
DB::transaction(function () use ($input) { DB::transaction(function () use ($input) {
$blogtags = self::MODEL; $input['status'] = isset($input['status']) ? 1 : 0;
$blogtags = new $blogtags(); $input['created_by'] = access()->user()->id;
$blogtags->name = $input['name'];
$blogtags->status = (isset($input['status']) && $input['status'] == 1)
? 1 : 0;
$blogtags->created_by = access()->user()->id;
if ($blogtags->save()) { if ($blogtag = BlogTag::create($input)) {
event(new BlogTagCreated($blogtags)); event(new BlogTagCreated($blogtag));
return true; return true;
} }
...@@ -68,27 +65,25 @@ class BlogTagsRepository extends BaseRepository ...@@ -68,27 +65,25 @@ class BlogTagsRepository extends BaseRepository
} }
/** /**
* @param Model $permission * @param \App\Models\BlogTags\BlogTag $blogtag
* @param $input * @param $input
* *
* @throws GeneralException * @throws \App\Exceptions\GeneralException
* *
* return bool * return bool
*/ */
public function update(Model $blogtags, array $input) public function update(BlogTag $blogtag, array $input)
{ {
if ($this->query()->where('name', $input['name'])->where('id', '!=', $blogtags->id)->first()) { if ($this->query()->where('name', $input['name'])->where('id', '!=', $blogtag->id)->first()) {
throw new GeneralException(trans('exceptions.backend.blogtags.already_exists')); throw new GeneralException(trans('exceptions.backend.blogtags.already_exists'));
} }
$blogtags->name = $input['name']; DB::transaction(function () use ($blogtag, $input) {
$blogtags->status = (isset($input['status']) && $input['status'] == 1) $input['status'] = isset($input['status']) ? 1 : 0;
? 1 : 0; $input['updated_by'] = access()->user()->id;
$blogtags->updated_by = access()->user()->id;
DB::transaction(function () use ($blogtags, $input) { if ($blogtag->update($input)) {
if ($blogtags->save()) { event(new BlogTagUpdated($blogtag));
event(new BlogTagUpdated($blogtags));
return true; return true;
} }
...@@ -100,13 +95,13 @@ class BlogTagsRepository extends BaseRepository ...@@ -100,13 +95,13 @@ class BlogTagsRepository extends BaseRepository
} }
/** /**
* @param Model $blogtag * @param \App\Models\BlogTags\BlogTag $blogtag
* *
* @throws GeneralException * @throws \App\Exceptions\GeneralException
* *
* @return bool * @return bool
*/ */
public function delete(Model $blogtag) public function delete(BlogTag $blogtag)
{ {
DB::transaction(function () use ($blogtag) { DB::transaction(function () use ($blogtag) {
if ($blogtag->delete()) { if ($blogtag->delete()) {
......
...@@ -23,31 +23,27 @@ class FaqsRepository extends BaseRepository ...@@ -23,31 +23,27 @@ class FaqsRepository extends BaseRepository
{ {
return $this->query() return $this->query()
->select([ ->select([
config('access.faqs_table').'.id', config('mdule.faqs.able').'.id',
config('access.faqs_table').'.question', config('odule.faqs.table').'.question',
config('access.faqs_table').'.answer', config('module.faqs.table').'.answer',
config('access.faqs_table').'.status', config('module.faqs.table').'.status',
config('access.faqs_table').'.created_at', config('module.faqs.table').'.created_at',
]); ]);
} }
/** /**
* @param array $input * @param array $input
* *
* @throws GeneralException * @throws \App\Exceptions\GeneralException
* *
* @return bool * @return bool
*/ */
public function create(array $input) public function create(array $input)
{ {
$faq = self::MODEL; $input['status'] = isset($input['status']) ? 1 : 0;
$faq = new $faq();
$faq->question = $input['question'];
$faq->answer = $input['answer'];
$faq->status = isset($input['status']) ? $input['status'] : 0;
//If faq saved successfully, then return true //If faq saved successfully, then return true
if ($faq->save()) { if (Faq::create($input)) {
return true; return true;
} }
...@@ -55,21 +51,19 @@ class FaqsRepository extends BaseRepository ...@@ -55,21 +51,19 @@ class FaqsRepository extends BaseRepository
} }
/** /**
* @param Model $permission * @param \App\Models\Faqs\Faq $faq
* @param $input * @param array $input
* *
* @throws GeneralException * @throws \App\Exceptions\GeneralException
* *
* return bool * return bool
*/ */
public function update(Model $faq, array $input) public function update(Faq $faq, array $input)
{ {
$faq->question = $input['question']; $input['status'] = isset($input['status']) ? 1 : 0;
$faq->answer = $input['answer'];
$faq->status = isset($input['status']) ? $input['status'] : 0;
//If faq updated successfully //If faq updated successfully
if ($faq->save()) { if ($faq->update($input)) {
return true; return true;
} }
...@@ -77,13 +71,13 @@ class FaqsRepository extends BaseRepository ...@@ -77,13 +71,13 @@ class FaqsRepository extends BaseRepository
} }
/** /**
* @param Model $blog * @param \App\Models\Faqs\Faq $faq
* *
* @throws GeneralException * @throws \App\Exceptions\GeneralException
* *
* @return bool * @return bool
*/ */
public function delete(Model $faq) public function delete(Faq $faq)
{ {
if ($faq->delete()) { if ($faq->delete()) {
return true; return true;
...@@ -93,14 +87,14 @@ class FaqsRepository extends BaseRepository ...@@ -93,14 +87,14 @@ class FaqsRepository extends BaseRepository
} }
/** /**
* @param Model $faq * @param \App\Models\Faqs\Faq $faq
* @param $status * @param string $status
* *
* @throws GeneralException * @throws \App\Exceptions\GeneralException
* *
* @return bool * @return bool
*/ */
public function mark(Model $faq, $status) public function mark(Faq $faq, $status)
{ {
$faq->status = $status; $faq->status = $status;
......
...@@ -224,9 +224,15 @@ class EloquentHistoryRepository implements HistoryContract ...@@ -224,9 +224,15 @@ class EloquentHistoryRepository implements HistoryContract
{ {
$assets = json_decode($assets, true); $assets = json_decode($assets, true);
$count = 1; $count = 1;
$asset_count = 1;
$flag = false;
if (is_array($assets) || $assets instanceof \Countable) {
$asset_count = count($assets) + 1; $asset_count = count($assets) + 1;
$flag = true;
}
if (count($assets)) { if ($flag) {
foreach ($assets as $name => $values) { foreach ($assets as $name => $values) {
$key = explode('_', $name)[0]; $key = explode('_', $name)[0];
$type = explode('_', $name)[1]; $type = explode('_', $name)[1];
......
<?php
namespace App\Repositories\Backend\Menu;
use App\Exceptions\GeneralException;
use App\Models\Menu\Menu;
use App\Repositories\BaseRepository;
use Illuminate\Database\Eloquent\Model;
/**
* Class MenuRepository.
*/
class MenuRepository extends BaseRepository
{
/**
* Associated Repository Model.
*/
const MODEL = Menu::class;
/**
* @return mixed
*/
public function getForDataTable()
{
return $this->query()
->select([
config('access.menus_table').'.id',
config('access.menus_table').'.name',
config('access.menus_table').'.type',
config('access.menus_table').'.created_at',
config('access.menus_table').'.updated_at',
]);
}
/**
* @param array $input
*
* @throws \App\Exceptions\GeneralException
*
* @return bool
*/
public function create(array $input)
{
if ($this->query()->where('name', $input['name'])->first()) {
throw new GeneralException(trans('exceptions.backend.menus.already_exists'));
}
$input['created_by'] = access()->user()->id;
if (Menu::create($input)) {
return true;
}
throw new GeneralException(trans('exceptions.backend.menus.create_error'));
}
/**
* @param \App\Models\Menu\Menu $menu
* @param $input
*
* @throws \App\Exceptions\GeneralException
*
* return bool
*/
public function update(Menu $menu, array $input)
{
if ($this->query()->where('name', $input['name'])->where('id', '!=', $menu->id)->first()) {
throw new GeneralException(trans('exceptions.backend.menus.already_exists'));
}
$input['updated_by'] = access()->user()->id;
if ($menu->update($input)) {
return true;
}
throw new GeneralException(trans('exceptions.backend.menus.update_error'));
}
/**
* @param \App\Models\Menu\Menu $menu
*
* @throws \App\Exceptions\GeneralException
*
* @return bool
*/
public function delete(Menu $menu)
{
if ($menu->delete()) {
return true;
}
throw new GeneralException(trans('exceptions.backend.menus.delete_error'));
}
}
...@@ -25,12 +25,14 @@ class PagesRepository extends BaseRepository ...@@ -25,12 +25,14 @@ class PagesRepository extends BaseRepository
public function getForDataTable() public function getForDataTable()
{ {
return $this->query() return $this->query()
->leftjoin(config('access.users_table'), config('access.users_table').'.id', '=', config('module.pages.table').'.created_by')
->select([ ->select([
config('module.pages.table').'.id', config('module.pages.table').'.id',
config('module.pages.table').'.title', config('module.pages.table').'.title',
config('module.pages.table').'.status', config('module.pages.table').'.status',
config('module.pages.table').'.created_at', config('module.pages.table').'.created_at',
config('module.pages.table').'.updated_at', config('module.pages.table').'.updated_at',
config('access.users_table').'.first_name as created_by',
]); ]);
} }
...@@ -47,10 +49,10 @@ class PagesRepository extends BaseRepository ...@@ -47,10 +49,10 @@ class PagesRepository extends BaseRepository
throw new GeneralException(trans('exceptions.backend.pages.already_exists')); throw new GeneralException(trans('exceptions.backend.pages.already_exists'));
} }
//Making extra fields // Making extra fields
$input['page_slug'] = str_slug($input['title']); $input['page_slug'] = str_slug($input['title']);
$input['status'] = isset($input['status']) ? 1 : 0; $input['status'] = isset($input['status']) ? 1 : 0;
$input['created_by'] = access()->user()->id; $input['created_by'] = auth()->id();
if ($page = Page::create($input)) { if ($page = Page::create($input)) {
event(new PageCreated($page)); event(new PageCreated($page));
...@@ -75,7 +77,7 @@ class PagesRepository extends BaseRepository ...@@ -75,7 +77,7 @@ class PagesRepository extends BaseRepository
throw new GeneralException(trans('exceptions.backend.pages.already_exists')); throw new GeneralException(trans('exceptions.backend.pages.already_exists'));
} }
//Making extra fields // Making extra fields
$input['page_slug'] = str_slug($input['title']); $input['page_slug'] = str_slug($input['title']);
$input['status'] = isset($input['status']) ? 1 : 0; $input['status'] = isset($input['status']) ? 1 : 0;
$input['updated_by'] = access()->user()->id; $input['updated_by'] = access()->user()->id;
......
...@@ -5,7 +5,7 @@ namespace App\Repositories\Backend\Settings; ...@@ -5,7 +5,7 @@ namespace App\Repositories\Backend\Settings;
use App\Exceptions\GeneralException; use App\Exceptions\GeneralException;
use App\Models\Settings\Setting; use App\Models\Settings\Setting;
use App\Repositories\BaseRepository; use App\Repositories\BaseRepository;
use DB; use Illuminate\Support\Facades\Storage;
/** /**
* Class SettingsRepository. * Class SettingsRepository.
...@@ -18,98 +18,96 @@ class SettingsRepository extends BaseRepository ...@@ -18,98 +18,96 @@ class SettingsRepository extends BaseRepository
const MODEL = Setting::class; const MODEL = Setting::class;
/** /**
* @param Model $permission * Site Logo Path.
* @param $input
* *
* @throws GeneralException * @var string
*/
protected $site_logo_path;
/**
* Favicon path.
*
* @var string
*/
protected $favicon_path;
/**
* Storage Class Object.
* *
* return bool * @var \Illuminate\Support\Facades\Storage
*/
protected $storage;
/**
* Constructor.
*/ */
public function update(Model $setting, array $input) public function __construct()
{ {
// Unsetting method and token values from array $this->site_logo_path = 'img'.DIRECTORY_SEPARATOR.'logo'.DIRECTORY_SEPARATOR;
unset($input['_method']); $this->favicon_path = 'img'.DIRECTORY_SEPARATOR.'favicon'.DIRECTORY_SEPARATOR;
unset($input['_token']); $this->storage = Storage::disk('public');
}
if (isset($input['logo'])) { /**
$image_upload = $this->uploadlogoimage($setting, $input['logo']); * @param \App\Models\Settings\Setting $setting
$input['logo'] = $image_upload; * @param array $input
*
* @throws \App\Exceptions\GeneralException
*
* @return bool
*/
public function update(Setting $setting, array $input)
{
if (!empty($input['logo'])) {
$this->removeLogo($setting, 'logo');
$input['logo'] = $this->uploadLogo($setting, $input['logo'], 'logo');
} }
if (isset($input['favicon'])) { if (!empty($input['favicon'])) {
$image_upload = $this->uploadfaviconimage($setting, $input['favicon']); $this->removeLogo($setting, 'favicon');
$input['favicon'] = $image_upload;
$input['favicon'] = $this->uploadLogo($setting, $input['favicon'], 'favicon');
} }
DB::transaction(function () use ($setting, $input) {
if ($setting->update($input)) { if ($setting->update($input)) {
return true; return true;
} }
throw new GeneralException(trans('exceptions.backend.settings.update_error')); throw new GeneralException(trans('exceptions.backend.settings.update_error'));
});
} }
/* /*
* Upload logo image * Upload logo image
*/ */
public function uploadlogoimage($setting, $logo) public function uploadLogo($setting, $logo, $type)
{ {
$image_name_ex = $logo->getClientOriginalExtension(); $path = $type == 'logo' ? $this->site_logo_path : $this->favicon_path;
if ($setting->logo) {
if (file_exists(public_path().'/img/site_logo/'.$setting->logo)) {
unlink('img/site_logo/'.$setting->logo);
}
}
$image_name = time().$logo->getClientOriginalName(); $image_name = time().$logo->getClientOriginalName();
$destinationPath = public_path('img/site_logo');
$logo->move($destinationPath, $image_name); $this->storage->put($path.$image_name, file_get_contents($logo->getRealPath()));
return $image_name; return $image_name;
} }
/* /*
* Upload favicon icon image * remove logo or favicon icon
*/ */
public function uploadfaviconimage($setting, $logo) public function removeLogo(Setting $setting, $type)
{ {
$image_name_ex = $logo->getClientOriginalExtension(); $path = $type == 'logo' ? $this->site_logo_path : $this->favicon_path;
if ($setting->favicon) { if ($setting->$type && $this->storage->exists($path.$setting->$type)) {
if (file_exists(public_path().'/img/favicon_icon/'.$setting->favicon)) { $this->storage->delete($path.$setting->$type);
unlink('img/favicon_icon/'.$setting->favicon);
}
} }
$image_name = time().$logo->getClientOriginalName(); $result = $setting->update([$type => null]);
$destinationPath = public_path('/img/favicon_icon');
$logo->move($destinationPath, $image_name);
return $image_name; if ($result) {
return true;
} }
/* throw new GeneralException(trans('exceptions.backend.settings.update_error'));
* remove logo or favicon icon
*/
public function removeicon($input)
{
$setting = $this->query()->get();
if ($input == 'logo') {
if ($setting[0]->logo) {
if (file_exists(public_path().'/img/site_logo/'.$setting[0]->logo)) {
unlink('img/site_logo/'.$setting[0]->logo);
}
$this->query()->update(['logo' => null]);
}
} else {
if ($setting[0]->favicon) {
if (file_exists(public_path().'/img/favicon_icon/'.$setting[0]->favicon)) {
unlink('img/favicon_icon/'.$setting[0]->favicon);
}
}
$this->query()->update(['favicon' => null]);
}
} }
} }
...@@ -79,6 +79,8 @@ class UserRepository extends BaseRepository ...@@ -79,6 +79,8 @@ class UserRepository extends BaseRepository
} }
/** /**
* Create User.
*
* @param array $data * @param array $data
* @param bool $provider * @param bool $provider
* *
...@@ -94,11 +96,28 @@ class UserRepository extends BaseRepository ...@@ -94,11 +96,28 @@ class UserRepository extends BaseRepository
$user->confirmation_code = md5(uniqid(mt_rand(), true)); $user->confirmation_code = md5(uniqid(mt_rand(), true));
$user->status = 1; $user->status = 1;
$user->password = $provider ? null : bcrypt($data['password']); $user->password = $provider ? null : bcrypt($data['password']);
$user->confirmed = $provider ? 1 : (config('access.users.confirm_email') ? 0 : 1);
$user->is_term_accept = $data['is_term_accept']; $user->is_term_accept = $data['is_term_accept'];
// If users require approval, confirmed is false regardless of account type
if (config('access.users.requires_approval')) {
$user->confirmed = 0; // No confirm e-mail sent, that defeats the purpose of manual approval
} elseif (config('access.users.confirm_email')) { // If user must confirm email
// If user is from social, already confirmed
if ($provider) {
$user->confirmed = 1; // E-mails are validated through the social platform
} else {
// Otherwise needs confirmation
$user->confirmed = 0;
$confirm = true;
}
} else {
// Otherwise both are off and confirmed is default
$user->confirmed = 1;
}
DB::transaction(function () use ($user) { DB::transaction(function () use ($user) {
if ($user->save()) { if ($user->save()) {
/* /*
* Add the default site role to the new user * Add the default site role to the new user
*/ */
...@@ -304,4 +323,20 @@ class UserRepository extends BaseRepository ...@@ -304,4 +323,20 @@ class UserRepository extends BaseRepository
return $token; return $token;
} }
/**
* @param $token
*
* @return mixed
*/
public function findByPasswordResetToken($token)
{
foreach (DB::table(config('auth.passwords.users.table'))->get() as $row) {
if (password_verify($token, $row->token)) {
return $this->findByEmail($row->email);
}
}
return false;
}
} }
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
"keywords": [ "keywords": [
"framework", "framework",
"laravel", "laravel",
"boilerplate" "boilerplate",
"adminpanel",
"rest-api"
], ],
"license": "MIT", "license": "MIT",
"type": "project", "type": "project",
...@@ -12,9 +14,10 @@ ...@@ -12,9 +14,10 @@
"php": ">=7.0.0", "php": ">=7.0.0",
"arcanedev/log-viewer": "^4.4", "arcanedev/log-viewer": "^4.4",
"arcanedev/no-captcha": "^5.0", "arcanedev/no-captcha": "^5.0",
"codedungeon/phpunit-result-printer": "0.4.4",
"creativeorange/gravatar": "~1.0", "creativeorange/gravatar": "~1.0",
"davejamesmiller/laravel-breadcrumbs": "^4.1", "davejamesmiller/laravel-breadcrumbs": "^4.1",
"doctrine/dbal": "^2.5", "doctrine/dbal": "^2.6",
"fideloper/proxy": "~3.3", "fideloper/proxy": "~3.3",
"hieu-le/active": "^3.5", "hieu-le/active": "^3.5",
"laravel/framework": "5.5.*", "laravel/framework": "5.5.*",
...@@ -27,16 +30,18 @@ ...@@ -27,16 +30,18 @@
}, },
"require-dev": { "require-dev": {
"barryvdh/laravel-debugbar": "^3.0", "barryvdh/laravel-debugbar": "^3.0",
"bvipul/generator": "v0.9.1", "bvipul/generator": "^0.9.1",
"filp/whoops": "~2.0", "filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4", "fzaninotto/faker": "~1.4",
"laravel/browser-kit-testing": "^1.0", "laravel/browser-kit-testing": "^2.0",
"mockery/mockery": "0.9.*", "mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0", "phpunit/phpunit": "~6.0",
"xethron/migrations-generator": "2.0.2" "xethron/migrations-generator": "2.0.2"
}, },
"autoload": { "autoload": {
"classmap": [ "classmap": [
"database/seeds",
"database/factories",
"database" "database"
], ],
"psr-4": { "psr-4": {
...@@ -51,8 +56,10 @@ ...@@ -51,8 +56,10 @@
"Tests\\": "tests/" "Tests\\": "tests/"
}, },
"classmap": [ "classmap": [
"tests/TestCase.php", "tests/TestCase.php"
"tests/BrowserKitTestCase.php" ],
"files": [
"tests/Utilities/helpers.php"
] ]
}, },
"scripts": { "scripts": {
......
This diff is collapsed.
...@@ -70,31 +70,6 @@ return [ ...@@ -70,31 +70,6 @@ return [
*/ */
'history_types_table' => 'history_types', 'history_types_table' => 'history_types',
/*
* Blog Catagories table used to store Blog Catagory
*/
'blog_categories_table' => 'blog_categories',
/*
* Blog Tags table used to store Blog Tag
*/
'blog_tags_table' => 'blog_tags',
/*
* Blog Tags table used to store Blog Tag
*/
'blogs_table' => 'blogs',
/*
* Blog Tags table used to store Blog Tag
*/
'blog_map_categories_table' => 'blog_map_categories',
/*
* Blog Tags table used to store Blog Tag
*/
'blog_map_tags_table' => 'blog_map_tags',
/* /*
* Notifications table used to store user notification * Notifications table used to store user notification
*/ */
...@@ -113,7 +88,7 @@ return [ ...@@ -113,7 +88,7 @@ return [
/* /*
* Whether or not public registration is on * Whether or not public registration is on
*/ */
'registration' => env('ENABLE_REGISTRATION', 'true'), 'registration' => env('ENABLE_REGISTRATION', true),
/* /*
* The role the user is assigned to when they sign up from the frontend, not namespaced * The role the user is assigned to when they sign up from the frontend, not namespaced
...@@ -130,6 +105,12 @@ return [ ...@@ -130,6 +105,12 @@ return [
* Whether or not the users email can be changed on the edit profile screen * Whether or not the users email can be changed on the edit profile screen
*/ */
'change_email' => false, 'change_email' => false,
/*
* Whether or not new users need to be approved by an administrator before logging in
* If this is set to true, then confirm_email is not in effect
*/
'requires_approval' => env('REQUIRES_APPROVAL', false),
], ],
/* /*
......
File mode changed from 100755 to 100644
...@@ -8,7 +8,7 @@ return [ ...@@ -8,7 +8,7 @@ return [
* *
* @var bool * @var bool
*/ */
'status' => true, 'status' => false,
/* /*
* Available languages * Available languages
...@@ -29,19 +29,19 @@ return [ ...@@ -29,19 +29,19 @@ return [
* Index 1 of sub-array is the PHP locale code for setlocale() * Index 1 of sub-array is the PHP locale code for setlocale()
* Index 2 of sub-array is whether or not to use RTL (right-to-left) css for this language * Index 2 of sub-array is whether or not to use RTL (right-to-left) css for this language
*/ */
'ar' => ['ar', 'ar_AR', true], // 'ar' => ['ar', 'ar_AR', true],
'da' => ['da', 'da_DK', false], // 'da' => ['da', 'da_DK', false],
'de' => ['de', 'de_DE', false], // 'de' => ['de', 'de_DE', false],
'el' => ['el', 'el_GR', false], // 'el' => ['el', 'el_GR', false],
'en' => ['en', 'en_US', false], 'en' => ['en', 'en_US', false],
'es' => ['es', 'es_ES', false], // 'es' => ['es', 'es_ES', false],
'fr' => ['fr', 'fr_FR', false], // 'fr' => ['fr', 'fr_FR', false],
'id' => ['id', 'id_ID', false], // 'id' => ['id', 'id_ID', false],
'it' => ['it', 'it_IT', false], // 'it' => ['it', 'it_IT', false],
'nl' => ['nl', 'nl_NL', false], // 'nl' => ['nl', 'nl_NL', false],
'pt_BR' => ['pt_BR', 'pt_BR', false], // 'pt_BR' => ['pt_BR', 'pt_BR', false],
'ru' => ['ru', 'ru-RU', false], // 'ru' => ['ru', 'ru-RU', false],
'sv' => ['sv', 'sv_SE', false], // 'sv' => ['sv', 'sv_SE', false],
'th' => ['th', 'th_TH', false], // 'th' => ['th', 'th_TH', false],
], ],
]; ];
...@@ -9,4 +9,16 @@ return [ ...@@ -9,4 +9,16 @@ return [
'placeholders_table' => 'email_template_placeholders', 'placeholders_table' => 'email_template_placeholders',
'types_table' => 'email_template_types', 'types_table' => 'email_template_types',
], ],
'blog_tags' => [
'table' => 'blog_tags',
],
'blog_categories' => [
'table' => 'blog_categories',
],
'blogs' => [
'table' => 'blogs',
],
'faqs' => [
'table' => 'faqs',
],
]; ];
<?php
use App\Models\Access\User\User;
use App\Models\BlogCategories\BlogCategory;
use Faker\Generator as Faker;
$factory->define(BlogCategory::class, function (Faker $faker) {
return [
'name' => $faker->word,
'status' => $faker->numberBetween(0, 1),
'created_by' => function () {
return factory(User::class)->create()->id;
},
];
});
<?php
use App\Models\Access\User\User;
use App\Models\Blogs\Blog;
use Faker\Generator as Faker;
$factory->define(Blog::class, function (Faker $faker) {
$status = [
'Published',
'Draft',
'InActive',
'Scheduled',
];
return [
'name' => $faker->sentence,
'publish_datetime' => $faker->dateTime(),
'featured_image' => 'logo.png',
'content' => $faker->paragraph(3),
'status' => $status[$faker->numberBetween(0, 3)],
'created_by' => function () {
return factory(User::class)->create()->id;
},
];
});
<?php
use App\Models\Access\User\User;
use App\Models\BlogTags\BlogTag;
use Faker\Generator as Faker;
$factory->define(BlogTag::class, function (Faker $faker) {
return [
'name' => $faker->word,
'status' => $faker->numberBetween(0, 1),
'created_by' => function () {
return factory(User::class)->create()->id;
},
];
});
<?php
use App\Models\Faqs\Faq;
use Faker\Generator as Faker;
$factory->define(Faq::class, function (Faker $faker) {
return [
'question' => rtrim($faker->sentence, '.').'?',
'answer' => $faker->paragraph,
'status' => $faker->numberBetween(0, 1),
];
});
<?php
use App\Models\Access\User\User;
use App\Models\Page\Page;
use Faker\Generator as Faker;
$factory->define(Page::class, function (Faker $faker) {
$title = $faker->sentence;
return [
'title' => $title,
'page_slug' => str_slug($title),
'description' => $faker->paragraph,
'created_by' => function () {
return factory(User::class)->create()->id;
},
];
});
<?php
use App\Models\Access\Permission\Permission;
use Faker\Generator;
/*
* Permissions
*/
$factory->define(Permission::class, function (Generator $faker) {
$name = $faker->word;
return [
'name' => $name,
'display_name' => $name,
'sort' => $faker->numberBetween(1, 100),
];
});
$factory->state(Permission::class, 'active', function () {
return [
'status' => 1,
];
});
$factory->state(Permission::class, 'inactive', function () {
return [
'status' => 0,
];
});
<?php
use App\Models\Access\Role\Role;
use Faker\Generator;
/*
* Roles
*/
$factory->define(Role::class, function (Generator $faker) {
return [
'name' => $faker->name,
'all' => 0,
'sort' => $faker->numberBetween(1, 100),
];
});
$factory->state(Role::class, 'admin', function () {
return [
'all' => 1,
];
});
$factory->state(Role::class, 'active', function () {
return [
'status' => 1,
];
});
$factory->state(Role::class, 'inactive', function () {
return [
'status' => 0,
];
});
<?php <?php
use App\Models\Access\Role\Role;
use App\Models\Access\User\User; use App\Models\Access\User\User;
use Faker\Generator; use Faker\Generator;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(User::class, function (Generator $faker) { $factory->define(User::class, function (Generator $faker) {
static $password; static $password;
return [ return [
'name' => $faker->name, 'first_name' => $faker->name,
'last_name' => $faker->name,
'email' => $faker->safeEmail, 'email' => $faker->safeEmail,
'password' => $password ?: $password = bcrypt('secret'), 'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => str_random(10),
'confirmation_code' => md5(uniqid(mt_rand(), true)), 'confirmation_code' => md5(uniqid(mt_rand(), true)),
'remember_token' => str_random(10),
]; ];
}); });
...@@ -50,20 +39,3 @@ $factory->state(User::class, 'unconfirmed', function () { ...@@ -50,20 +39,3 @@ $factory->state(User::class, 'unconfirmed', function () {
'confirmed' => 0, 'confirmed' => 0,
]; ];
}); });
/*
* Roles
*/
$factory->define(Role::class, function (Generator $faker) {
return [
'name' => $faker->name,
'all' => 0,
'sort' => $faker->numberBetween(1, 100),
];
});
$factory->state(Role::class, 'admin', function () {
return [
'all' => 1,
];
});
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateMenusTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('menus', function (Blueprint $table) {
$table->increments('id')->unsigned();
$table->enum('type', ['backend', 'frontend']);
$table->string('name');
$table->text('items')->nullable();
$table->integer('created_by')->unsigned();
$table->integer('updated_by')->unsigned()->nullable();
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('menus');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNullConstraintOnCreatedByOnUserTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->integer('created_by')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNullConstraintOnCreatedByOnRoleTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('roles', function (Blueprint $table) {
$table->integer('created_by')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNullConstraintOnCreatedByOnPermissionTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('permissions', function (Blueprint $table) {
$table->integer('created_by')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
...@@ -26,8 +26,8 @@ class UserTableSeeder extends Seeder ...@@ -26,8 +26,8 @@ class UserTableSeeder extends Seeder
//Add the master administrator, user id of 1 //Add the master administrator, user id of 1
$users = [ $users = [
[ [
'first_name' => 'Admin Istrator', 'first_name' => 'Viral',
'last_name' => 'Admin Istrator', 'last_name' => 'Solani',
'email' => 'admin@admin.com', 'email' => 'admin@admin.com',
'password' => bcrypt('1234'), 'password' => bcrypt('1234'),
'confirmation_code' => md5(uniqid(mt_rand(), true)), 'confirmation_code' => md5(uniqid(mt_rand(), true)),
...@@ -39,8 +39,8 @@ class UserTableSeeder extends Seeder ...@@ -39,8 +39,8 @@ class UserTableSeeder extends Seeder
'deleted_at' => null, 'deleted_at' => null,
], ],
[ [
'first_name' => 'Backend User', 'first_name' => 'Vipul',
'last_name' => 'Admin Istrator', 'last_name' => 'Basapati',
'email' => 'executive@executive.com', 'email' => 'executive@executive.com',
'password' => bcrypt('1234'), 'password' => bcrypt('1234'),
'confirmation_code' => md5(uniqid(mt_rand(), true)), 'confirmation_code' => md5(uniqid(mt_rand(), true)),
...@@ -52,8 +52,8 @@ class UserTableSeeder extends Seeder ...@@ -52,8 +52,8 @@ class UserTableSeeder extends Seeder
'deleted_at' => null, 'deleted_at' => null,
], ],
[ [
'first_name' => 'Default User', 'first_name' => 'User',
'last_name' => 'Admin Istrator', 'last_name' => 'Test',
'email' => 'user@user.com', 'email' => 'user@user.com',
'password' => bcrypt('1234'), 'password' => bcrypt('1234'),
'confirmation_code' => md5(uniqid(mt_rand(), true)), 'confirmation_code' => md5(uniqid(mt_rand(), true)),
......
...@@ -24,6 +24,8 @@ class DatabaseSeeder extends Seeder ...@@ -24,6 +24,8 @@ class DatabaseSeeder extends Seeder
$this->call(EmailTemplateTableSeeder::class); $this->call(EmailTemplateTableSeeder::class);
$this->call(SettingsTableSeeder::class); $this->call(SettingsTableSeeder::class);
$this->call(PagesTableSeeder::class); $this->call(PagesTableSeeder::class);
$this->call(MenuTableSeeder::class);
$this->call(ModulesTableSeeder::class);
Model::reguard(); Model::reguard();
} }
......
<?php
use Carbon\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class MenuTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table(config('access.menus_table'))->truncate();
$menu = [
'id' => 1,
'type' => 'backend',
'name' => 'Backend Sidebar Menu',
'items' => '[{"view_permission_id":"view-access-management","icon":"fa-users","open_in_new_tab":0,"url_type":"route","url":"","name":"Access Management","id":11,"content":"Access Management","children":[{"view_permission_id":"view-user-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.user.index","name":"User Management","id":12,"content":"User Management"},{"view_permission_id":"view-role-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.role.index","name":"Role Management","id":13,"content":"Role Management"},{"view_permission_id":"view-permission-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.permission.index","name":"Permission Management","id":14,"content":"Permission Management"}]},{"view_permission_id":"view-module","icon":"fa-wrench","open_in_new_tab":0,"url_type":"route","url":"admin.modules.index","name":"Module","id":1,"content":"Module"},{"view_permission_id":"view-menu","icon":"fa-bars","open_in_new_tab":0,"url_type":"route","url":"admin.menus.index","name":"Menus","id":3,"content":"Menus"},{"view_permission_id":"view-page","icon":"fa-file-text","open_in_new_tab":0,"url_type":"route","url":"admin.pages.index","name":"Pages","id":2,"content":"Pages"},{"view_permission_id":"view-email-template","icon":"fa-envelope","open_in_new_tab":0,"url_type":"route","url":"admin.emailtemplates.index","name":"Email Templates","id":8,"content":"Email Templates"},{"view_permission_id":"edit-settings","icon":"fa-gear","open_in_new_tab":0,"url_type":"route","url":"admin.settings.edit?id=1","name":"Settings","id":9,"content":"Settings"},{"view_permission_id":"view-blog","icon":"fa-commenting","open_in_new_tab":0,"url_type":"route","url":"","name":"Blog Management","id":15,"content":"Blog Management","children":[{"view_permission_id":"view-blog-category","open_in_new_tab":0,"url_type":"route","url":"admin.blogCategories.index","name":"Blog Category Management","id":16,"content":"Blog Category Management"},{"view_permission_id":"view-blog-tag","open_in_new_tab":0,"url_type":"route","url":"admin.blogTags.index","name":"Blog Tag Management","id":17,"content":"Blog Tag Management"},{"view_permission_id":"view-blog","open_in_new_tab":0,"url_type":"route","url":"admin.blogs.index","name":"Blog Management","id":18,"content":"Blog Management"}]},{"view_permission_id":"view-faq","icon":"fa-question-circle","open_in_new_tab":0,"url_type":"route","url":"admin.faqs.index","name":"Faq Management","id":19,"content":"Faq Management"}]',
'created_by' => 1,
'created_at' => Carbon::now(),
];
DB::table(config('access.menus_table'))->insert($menu);
}
}
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