Commit 0e554762 authored by Viral Solani's avatar Viral Solani
parents d005153a 8ae41913
......@@ -26,4 +26,4 @@ public/css
public/js
composer.lock
public/img/backend/blog_images/*
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
* @var array
*/
protected $commands = [
'App\Console\Commands\ModuleGenerator',
];
/**
......
......@@ -14,13 +14,13 @@ class BlogCategoryCreated
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @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
/**
* @var
*/
public $blogtags;
public $blogtag;
/**
* @param $blogtags
* @param $blogtag
*/
public function __construct($blogtags)
public function __construct($blogtag)
{
$this->blogtags = $blogtags;
$this->blogtag = $blogtag;
}
}
......@@ -17,21 +17,18 @@ use App\Repositories\Backend\BlogCategories\BlogCategoriesRepository;
*/
class BlogCategoriesController extends Controller
{
/**
* @var BlogCategoriesRepository
*/
protected $blogcategories;
protected $blogcategory;
/**
* @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
*/
......@@ -41,7 +38,7 @@ class BlogCategoriesController extends Controller
}
/**
* @param CreateBlogCategoriesRequest $request
* @param \App\Http\Requests\Backend\BlogCategories\CreateBlogCategoriesRequest $request
*
* @return mixed
*/
......@@ -51,52 +48,58 @@ class BlogCategoriesController extends Controller
}
/**
* @param StoreBlogCategoriesRequest $request
* @param \App\Http\Requests\Backend\BlogCategories\StoreBlogCategoriesRequest $request
*
* @return mixed
*/
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 EditBlogCategoriesRequest $request
* @param \App\Models\BlogCategories\BlogCategory $blogcategory
* @param \App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest $request
*
* @return mixed
*/
public function edit(BlogCategory $blogcategory, EditBlogCategoriesRequest $request)
{
return view('backend.blogcategories.edit')
->withBlogcategory($blogcategory);
->with('blogcategory', $blogcategory);
}
/**
* @param BlogCategory $blogcategory
* @param UpdateBlogCategoriesRequest $request
* @param \App\Models\BlogCategories\BlogCategory $blogcategory
* @param \App\Http\Requests\Backend\BlogCategories\UpdateBlogCategoriesRequest $request
*
* @return mixed
*/
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 DeleteBlogCategoriesRequest $request
* @param \App\Models\BlogCategories\BlogCategory $blogcategory
* @param \App\Http\Requests\Backend\BlogCategories\DeleteBlogCategoriesRequest $request
*
* @return mixed
*/
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;
*/
class BlogCategoriesTableController extends Controller
{
/**
* @var BlogCategoriesRepository
*/
protected $blogcategories;
protected $blogcategory;
/**
* @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
*/
public function __invoke(ManageBlogCategoriesRequest $request)
{
return Datatables::of($this->blogcategories->getForDataTable())
return Datatables::of($this->blogcategory->getForDataTable())
->escapeColumns(['name'])
->addColumn('status', function ($blogcategories) {
if ($blogcategories->status) {
return '<span class="label label-success">Active</span>';
}
return '<span class="label label-danger">Inactive</span>';
->addColumn('status', function ($blogcategory) {
return $blogcategory->status_label;
})
->addColumn('created_by', function ($blogcategories) {
return $blogcategories->user_name;
->addColumn('created_by', function ($blogcategory) {
return $blogcategory->user_name;
})
->addColumn('created_at', function ($blogcategories) {
return Carbon::parse($blogcategories->created_at)->toDateString();
->addColumn('created_at', function ($blogcategory) {
return Carbon::parse($blogcategory->created_at)->toDateString();
})
->addColumn('actions', function ($blogcategories) {
return $blogcategories->action_buttons;
->addColumn('actions', function ($blogcategory) {
return $blogcategory->action_buttons;
})
->make(true);
}
......
......@@ -18,20 +18,20 @@ use App\Repositories\Backend\BlogTags\BlogTagsRepository;
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
*/
......@@ -41,7 +41,7 @@ class BlogTagsController extends Controller
}
/**
* @param CreateBlogTagsRequest $request
* @param \App\Http\Requests\Backend\BlogTags\CreateBlogTagsRequest $request
*
* @return mixed
*/
......@@ -51,52 +51,58 @@ class BlogTagsController extends Controller
}
/**
* @param StoreblogtagsRequest $request
* @param \App\Http\Requests\Backend\BlogTags\StoreBlogTagsRequest $request
*
* @return mixed
*/
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 EditBlogTagsRequest $request
* @param \App\Models\BlogTags\BlogTag $blogtag
* @param \App\Http\Requests\Backend\BlogTags\EditBlogTagsRequest $request
*
* @return mixed
*/
public function edit(BlogTag $blogtag, EditBlogTagsRequest $request)
{
return view('backend.blogtags.edit')
->withBlogtag($blogtag);
->with('blogtag', $blogtag);
}
/**
* @param BlogTag $blogtag
* @param UpdateblogtagsRequest $request
* @param \App\Models\BlogTags\BlogTag $blogtag
* @param \App\Http\Requests\Backend\BlogTags\UpdateBlogTagsRequest $request
*
* @return mixed
*/
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 DeleteBlogTagsRequest $request
* @param \App\Models\BlogTags\BlogTag $blogtag
* @param \App\Http\Requests\Backend\BlogTags\DeleteBlogTagsRequest $request
*
* @return mixed
*/
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;
class BlogTagsTableController extends Controller
{
/**
* @var BlogTagsRepository
* @var \App\Repositories\Backend\BlogTags\BlogTagsRepository
*/
protected $blogtags;
/**
* @param BlogTagsRepository $cmspages
* @param \App\Repositories\Backend\BlogTags\BlogTagsRepository $blogtags
*/
public function __construct(BlogTagsRepository $blogtags)
{
......@@ -27,7 +27,7 @@ class BlogTagsTableController extends Controller
}
/**
* @param ManageBlogTagsRequest $request
* @param \App\Http\Requests\Backend\BlogTags\ManageBlogTagsRequest $request
*
* @return mixed
*/
......@@ -36,11 +36,7 @@ class BlogTagsTableController extends Controller
return Datatables::of($this->blogtags->getForDataTable())
->escapeColumns(['name'])
->addColumn('status', function ($blogtags) {
if ($blogtags->status) {
return '<span class="label label-success">Active</span>';
}
return '<span class="label label-danger">Inactive</span>';
return $blogtags->status_label;
})
->addColumn('created_by', function ($blogtags) {
return $blogtags->user_name;
......
......@@ -29,18 +29,18 @@ class BlogsController extends Controller
/**
* @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
*/
......@@ -52,14 +52,14 @@ class BlogsController extends Controller
}
/**
* @param ManageBlogsRequest $request
* @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request
*
* @return mixed
*/
public function create(ManageBlogsRequest $request)
{
$blogCategories = BlogCategory::getSelectData();
$blogTags = BlogTag::getSelectData();
$blogCategories = BlogCategory::getSelectData();
return view('backend.blogs.create')->with([
'blogCategories' => $blogCategories,
......@@ -69,22 +69,22 @@ class BlogsController extends Controller
}
/**
* @param StoreBlogsRequest $request
* @param \App\Http\Requests\Backend\Blogs\StoreBlogsRequest $request
*
* @return mixed
*/
public function store(StoreBlogsRequest $request)
{
$input = $request->all();
$this->blogs->create($input, $tagsArray, $categoriesArray);
$this->blog->create($request->except('_token'));
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 ManageBlogsRequest $request
* @param \App\Models\Blogs\Blog $blog
* @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request
*
* @return mixed
*/
......@@ -107,8 +107,8 @@ class BlogsController extends Controller
}
/**
* @param Blog $blog
* @param UpdateBlogsRequest $request
* @param \App\Models\Blogs\Blog $blog
* @param \App\Http\Requests\Backend\Blogs\UpdateBlogsRequest $request
*
* @return mixed
*/
......@@ -116,21 +116,25 @@ class BlogsController extends Controller
{
$input = $request->all();
$this->blogs->update($blog, $input);
$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 ManageBlogsRequest $request
* @param \App\Models\Blogs\Blog $blog
* @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request
*
* @return mixed
*/
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'));
return redirect()
->route('admin.blogs.index')
->with('flash_success', trans('alerts.backend.blogs.deleted'));
}
}
......@@ -5,7 +5,6 @@ namespace App\Http\Controllers\Backend\Blogs;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Blogs\ManageBlogsRequest;
use App\Repositories\Backend\Blogs\BlogsRepository;
use Carbon\Carbon;
use Yajra\DataTables\Facades\DataTables;
/**
......@@ -13,13 +12,10 @@ use Yajra\DataTables\Facades\DataTables;
*/
class BlogsTableController extends Controller
{
/**
* @var BlogsRepository
*/
protected $blogs;
/**
* @param BlogsRepository $cmspages
* @param \App\Repositories\Backend\Blogs\BlogsRepository $cmspages
*/
public function __construct(BlogsRepository $blogs)
{
......@@ -27,7 +23,7 @@ class BlogsTableController extends Controller
}
/**
* @param ManageBlogsRequest $request
* @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request
*
* @return mixed
*/
......@@ -39,13 +35,13 @@ class BlogsTableController extends Controller
return $blogs->status;
})
->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) {
return $blogs->user_name;
})
->addColumn('created_at', function ($blogs) {
return Carbon::parse($blogs->created_at)->toDateString();
return $blogs->created_at->toDateString();
})
->addColumn('actions', function ($blogs) {
return $blogs->action_buttons;
......
<?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;
class FaqsController extends Controller
{
/**
* @var FaqsRepository
*/
protected $faqs;
protected $faq;
/**
* @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.
*
* @param \App\Http\Requests\Backend\Faqs\ManageFaqsRequest $request
*
* @return \Illuminate\Http\Response
*/
public function index(ManageFaqsRequest $request)
{
//Status array
$status = [1 => 'Active', 0 => 'Inactive'];
return view('backend.faqs.index')->withStatus($status);
return view('backend.faqs.index');
}
/**
* Show the form for creating a new resource.
*
* @param \App\Http\Requests\Backend\Faqs\CreateFaqsRequest $request
*
* @return \Illuminate\Http\Response
*/
public function create(CreateFaqsRequest $request)
......@@ -53,7 +51,7 @@ class FaqsController extends Controller
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Http\Requests\Backend\Faqs\StoreFaqsRequest $request
*
* @return \Illuminate\Http\Response
*/
......@@ -61,39 +59,32 @@ class FaqsController extends Controller
{
$input = $request->all();
$this->faqs->create($input);
$this->faq->create($input);
return redirect()->route('admin.faqs.index')->withFlashSuccess(trans('alerts.backend.faqs.created'));
}
/**
* Display the specified resource.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show($id)
{
return redirect()
->route('admin.faqs.index')
->with('flash_success', trans('alerts.backend.faqs.created'));
}
/**
* 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
*/
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.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \App\Http\Requests\Backend\Faqs\UpdateFaqsRequest $request
* @param \App\Models\Faqs\Faq $id
*
* @return \Illuminate\Http\Response
*/
......@@ -101,37 +92,27 @@ class FaqsController extends Controller
{
$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.
*
* @param int $id
* @param \App\Models\Faqs\Faq $faq
* @param \App\Http\Requests\Backend\Faqs\DeleteFaqsRequest $request
*
* @return \Illuminate\Http\Response
*/
public function destroy(Faq $faq, DeleteFaqsRequest $request)
{
$this->faqs->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);
$this->faq->delete($faq);
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'));
}
}
......@@ -17,9 +17,6 @@ use App\Repositories\Backend\Pages\PagesRepository;
*/
class PagesController extends Controller
{
/**
* @var PagesRepository
*/
protected $pages;
/**
......
......@@ -13,9 +13,6 @@ use Yajra\DataTables\Facades\DataTables;
*/
class PagesTableController extends Controller
{
/**
* @var PagesRepository
*/
protected $pages;
/**
......
......@@ -39,7 +39,7 @@ class StoreBlogTagsRequest extends Request
public function messages()
{
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.',
];
}
......
......@@ -39,7 +39,7 @@ class UpdateBlogTagsRequest extends Request
public function messages()
{
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.',
];
}
......
......@@ -18,8 +18,8 @@ class BlogCategoryEventListener
public function onCreated($event)
{
history()->withType($this->history_slug)
->withEntity($event->blogcategories->id)
->withText('trans("history.backend.blogcategories.created") <strong>'.$event->blogcategories->name.'</strong>')
->withEntity($event->blogcategory->id)
->withText('trans("history.backend.blogcategories.created") <strong>'.$event->blogcategory->name.'</strong>')
->withIcon('plus')
->withClass('bg-green')
->log();
......@@ -31,8 +31,8 @@ class BlogCategoryEventListener
public function onUpdated($event)
{
history()->withType($this->history_slug)
->withEntity($event->blogcategories->id)
->withText('trans("history.backend.blogcategories.updated") <strong>'.$event->blogcategories->name.'</strong>')
->withEntity($event->blogcategory->id)
->withText('trans("history.backend.blogcategories.updated") <strong>'.$event->blogcategory->name.'</strong>')
->withIcon('save')
->withClass('bg-aqua')
->log();
......@@ -44,8 +44,8 @@ class BlogCategoryEventListener
public function onDeleted($event)
{
history()->withType($this->history_slug)
->withEntity($event->blogcategories->id)
->withText('trans("history.backend.blogcategories.deleted") <strong>'.$event->blogcategories->name.'</strong>')
->withEntity($event->blogcategory->id)
->withText('trans("history.backend.blogcategories.deleted") <strong>'.$event->blogcategory->name.'</strong>')
->withIcon('trash')
->withClass('bg-maroon')
->log();
......
......@@ -18,8 +18,8 @@ class BlogTagEventListener
public function onCreated($event)
{
history()->withType($this->history_slug)
->withEntity($event->blogtags->id)
->withText('trans("history.backend.blogtags.created") <strong>'.$event->blogtags->name.'</strong>')
->withEntity($event->blogtag->id)
->withText('trans("history.backend.blogtags.created") <strong>'.$event->blogtag->name.'</strong>')
->withIcon('plus')
->withClass('bg-green')
->log();
......@@ -31,8 +31,8 @@ class BlogTagEventListener
public function onUpdated($event)
{
history()->withType($this->history_slug)
->withEntity($event->blogtags->id)
->withText('trans("history.backend.blogtags.updated") <strong>'.$event->blogtags->name.'</strong>')
->withEntity($event->blogtag->id)
->withText('trans("history.backend.blogtags.updated") <strong>'.$event->blogtag->name.'</strong>')
->withIcon('save')
->withClass('bg-aqua')
->log();
......@@ -44,8 +44,8 @@ class BlogTagEventListener
public function onDeleted($event)
{
history()->withType($this->history_slug)
->withEntity($event->blogtags->id)
->withText('trans("history.backend.blogtags.deleted") <strong>'.$event->blogtags->name.'</strong>')
->withEntity($event->blogtag->id)
->withText('trans("history.backend.blogtags.deleted") <strong>'.$event->blogtag->name.'</strong>')
->withIcon('trash')
->withClass('bg-maroon')
->log();
......
......@@ -29,6 +29,6 @@ class BlogCategory extends BaseModel
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->table = config('access.blog_categories_table');
$this->table = config('module.blog_categories.table');
}
}
......@@ -17,4 +17,24 @@ trait BlogCategoryAttribute
'.$this->getDeleteButtonAttribute('delete-blog-category', 'admin.blogcategories.destroy').'
</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;
}
}
......@@ -11,11 +11,10 @@ class BlogMapCategory extends BaseModel
*
* @var string
*/
protected $table;
protected $table = 'blog_map_categories';
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->table = config('access.blog_map_categories_table');
}
}
......@@ -11,11 +11,10 @@ class BlogMapTag extends BaseModel
*
* @var string
*/
protected $table;
protected $table = 'blog_map_tags';
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->table = config('access.blog_map_tags');
}
}
......@@ -29,6 +29,6 @@ class BlogTag extends BaseModel
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->table = config('access.blog_tags_table');
$this->table = config('module.blog_tags.table');
}
}
......@@ -17,4 +17,24 @@ trait BlogTagAttribute
'.$this->getDeleteButtonAttribute('delete-blog-tag', 'admin.blogtags.destroy').'
</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;
}
}
......@@ -17,6 +17,26 @@ class Blog extends BaseModel
// 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.
*
......@@ -27,6 +47,6 @@ class Blog extends BaseModel
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->table = config('access.blogs_table');
$this->table = config('module.blogs.table');
}
}
......@@ -32,6 +32,6 @@ class Faq extends BaseModel
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->table = config('access.faqs_table');
$this->table = config('module.faqs.table');
}
}
......@@ -26,13 +26,13 @@ class BlogCategoriesRepository extends BaseRepository
public function getForDataTable()
{
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([
config('access.blog_categories_table').'.id',
config('access.blog_categories_table').'.name',
config('access.blog_categories_table').'.status',
config('access.blog_categories_table').'.created_by',
config('access.blog_categories_table').'.created_at',
config('module.blog_categories.table').'.id',
config('module.blog_categories.table').'.name',
config('module.blog_categories.table').'.status',
config('module.blog_categories.table').'.created_by',
config('module.blog_categories.table').'.created_at',
config('access.users_table').'.first_name as user_name',
]);
}
......@@ -40,7 +40,7 @@ class BlogCategoriesRepository extends BaseRepository
/**
* @param array $input
*
* @throws GeneralException
* @throws \App\Exceptions\GeneralException
*
* @return bool
*/
......@@ -49,16 +49,13 @@ class BlogCategoriesRepository extends BaseRepository
if ($this->query()->where('name', $input['name'])->first()) {
throw new GeneralException(trans('exceptions.backend.blogcategories.already_exists'));
}
DB::transaction(function () use ($input) {
$blogcategories = self::MODEL;
$blogcategories = new $blogcategories();
$blogcategories->name = $input['name'];
$blogcategories->status = (isset($input['status']) && $input['status'] == 1)
? 1 : 0;
$blogcategories->created_by = access()->user()->id;
$input['status'] = isset($input['status']) ? 1 : 0;
$input['created_by'] = access()->user()->id;
if ($blogcategories->save()) {
event(new BlogCategoryCreated($blogcategories));
if ($blogcategory = BlogCategory::create($input)) {
event(new BlogCategoryCreated($blogcategory));
return true;
}
......@@ -68,44 +65,41 @@ class BlogCategoriesRepository extends BaseRepository
}
/**
* @param Model $permission
* @param \App\Models\BlogCategories\BlogCategory $blogcategory
* @param $input
*
* @throws GeneralException
* @throws \App\Exceptions\GeneralException
*
* 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'));
}
$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) {
if ($blogcategories->save()) {
event(new BlogCategoryUpdated($blogcategories));
DB::transaction(function () use ($blogcategory, $input) {
$input['status'] = isset($input['status']) ? 1 : 0;
$input['updated_by'] = access()->user()->id;
if ($blogcategory->update($input)) {
event(new BlogCategoryUpdated($blogcategory));
return true;
}
throw new GeneralException(
trans('exceptions.backend.blogcategories.update_error')
);
throw new GeneralException(trans('exceptions.backend.blogcategories.update_error'));
});
}
/**
* @param Model $blogcategory
* @param \App\Models\BlogCategories\BlogCategory $blogcategory
*
* @throws GeneralException
* @throws \App\Exceptions\GeneralException
*
* @return bool
*/
public function delete(Model $blogcategory)
public function delete(BlogCategory $blogcategory)
{
DB::transaction(function () use ($blogcategory) {
if ($blogcategory->delete()) {
......
......@@ -26,13 +26,13 @@ class BlogTagsRepository extends BaseRepository
public function getForDataTable()
{
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([
config('access.blog_tags_table').'.id',
config('access.blog_tags_table').'.name',
config('access.blog_tags_table').'.status',
config('access.blog_tags_table').'.created_by',
config('access.blog_tags_table').'.created_at',
config('module.blog_tags.table').'.id',
config('module.blog_tags.table').'.name',
config('module.blog_tags.table').'.status',
config('module.blog_tags.table').'.created_by',
config('module.blog_tags.table').'.created_at',
config('access.users_table').'.first_name as user_name',
]);
}
......@@ -40,7 +40,7 @@ class BlogTagsRepository extends BaseRepository
/**
* @param array $input
*
* @throws GeneralException
* @throws \App\Exceptions\GeneralException
*
* @return bool
*/
......@@ -49,16 +49,13 @@ class BlogTagsRepository extends BaseRepository
if ($this->query()->where('name', $input['name'])->first()) {
throw new GeneralException(trans('exceptions.backend.blogtags.already_exists'));
}
DB::transaction(function () use ($input) {
$blogtags = self::MODEL;
$blogtags = new $blogtags();
$blogtags->name = $input['name'];
$blogtags->status = (isset($input['status']) && $input['status'] == 1)
? 1 : 0;
$blogtags->created_by = access()->user()->id;
$input['status'] = isset($input['status']) ? 1 : 0;
$input['created_by'] = access()->user()->id;
if ($blogtags->save()) {
event(new BlogTagCreated($blogtags));
if ($blogtag = BlogTag::create($input)) {
event(new BlogTagCreated($blogtag));
return true;
}
......@@ -68,27 +65,25 @@ class BlogTagsRepository extends BaseRepository
}
/**
* @param Model $permission
* @param \App\Models\BlogTags\BlogTag $blogtag
* @param $input
*
* @throws GeneralException
* @throws \App\Exceptions\GeneralException
*
* 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'));
}
$blogtags->name = $input['name'];
$blogtags->status = (isset($input['status']) && $input['status'] == 1)
? 1 : 0;
$blogtags->updated_by = access()->user()->id;
DB::transaction(function () use ($blogtag, $input) {
$input['status'] = isset($input['status']) ? 1 : 0;
$input['updated_by'] = access()->user()->id;
DB::transaction(function () use ($blogtags, $input) {
if ($blogtags->save()) {
event(new BlogTagUpdated($blogtags));
if ($blogtag->update($input)) {
event(new BlogTagUpdated($blogtag));
return true;
}
......@@ -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
*/
public function delete(Model $blogtag)
public function delete(BlogTag $blogtag)
{
DB::transaction(function () use ($blogtag) {
if ($blogtag->delete()) {
......
......@@ -7,9 +7,11 @@ use App\Events\Backend\Blogs\BlogDeleted;
use App\Events\Backend\Blogs\BlogUpdated;
use App\Exceptions\GeneralException;
use App\Http\Utilities\FileUploads;
use App\Models\BlogCategories\BlogCategory;
use App\Models\BlogMapCategories\BlogMapCategory;
use App\Models\BlogMapTags\BlogMapTag;
use App\Models\Blogs\Blog;
use App\Models\BlogTags\BlogTag;
use App\Repositories\BaseRepository;
use Carbon\Carbon;
use DB;
......@@ -30,14 +32,14 @@ class BlogsRepository extends BaseRepository
public function getForDataTable()
{
return $this->query()
->leftjoin(config('access.users_table'), config('access.users_table').'.id', '=', config('access.blogs_table').'.created_by')
->leftjoin(config('access.users_table'), config('access.users_table').'.id', '=', config('module.blogs.table').'.created_by')
->select([
config('access.blogs_table').'.id',
config('access.blogs_table').'.name',
config('access.blogs_table').'.publish_datetime',
config('access.blogs_table').'.status',
config('access.blogs_table').'.created_by',
config('access.blogs_table').'.created_at',
config('module.blogs.table').'.id',
config('module.blogs.table').'.name',
config('module.blogs.table').'.publish_datetime',
config('module.blogs.table').'.status',
config('module.blogs.table').'.created_by',
config('module.blogs.table').'.created_at',
config('access.users_table').'.first_name as user_name',
]);
}
......@@ -45,46 +47,34 @@ class BlogsRepository extends BaseRepository
/**
* @param array $input
*
* @throws GeneralException
* @throws \App\Exceptions\GeneralException
*
* @return bool
*/
public function create(array $input)
{
$tagsArray = $this->createTagsArray($input['tags']);
$categoriesArray = $this->createCategoriesArray($input['categories']);
$tagsArray = $this->createTags($input['tags']);
$categoriesArray = $this->createCategories($input['categories']);
unset($input['tags'], $input['categories']);
DB::transaction(function () use ($input, $tagsArray, $categoriesArray) {
$blogs = self::MODEL;
$blogs = new $blogs();
$blogs->name = $input['name'];
$blogs->slug = str_slug($input['name']);
$blogs->content = $input['content'];
$blogs->publish_datetime = Carbon::parse($input['publish_datetime']);
// Image Upload
$image = $this->uploadImage($input);
$blogs->featured_image = $image['featured_image'];
$blogs->meta_title = $input['meta_title'];
$blogs->cannonical_link = $input['cannonical_link'];
$blogs->meta_keywords = $input['meta_keywords'];
$blogs->meta_description = $input['meta_description'];
$blogs->status = $input['status'];
$blogs->created_by = access()->user()->id;
if ($blogs->save()) {
$input['slug'] = str_slug($input['name']);
$input['publish_datetime'] = Carbon::parse($input['publish_datetime']);
$input = $this->uploadImage($input);
$input['created_by'] = access()->user()->id;
if ($blog = Blog::create($input)) {
// Inserting associated category's id in mapper table
if (count($categoriesArray)) {
$blogs->categories()->sync($categoriesArray);
$blog->categories()->sync($categoriesArray);
}
// Inserting associated tag's id in mapper table
if (count($tagsArray)) {
$blogs->tags()->sync($tagsArray);
$blog->tags()->sync($tagsArray);
}
event(new BlogCreated($blogs));
event(new BlogCreated($blog));
return true;
}
......@@ -96,46 +86,39 @@ class BlogsRepository extends BaseRepository
/**
* Update Blog.
*
* @param $blogs
* @param array $input
* @param \App\Models\Blogs\Blog $blog
* @param array $input
*/
public function update($blogs, array $input)
public function update(Blog $blog, array $input)
{
$tagsArray = $this->createTagsArray($input['tags']);
$categoriesArray = $this->createCategoriesArray($input['categories']);
$blogs->name = $input['name'];
$blogs->slug = str_slug($input['name']);
$blogs->content = $input['content'];
$blogs->publish_datetime = Carbon::parse($input['publish_datetime']);
$blogs->meta_title = $input['meta_title'];
$blogs->cannonical_link = $input['cannonical_link'];
$blogs->meta_keywords = $input['meta_keywords'];
$blogs->meta_description = $input['meta_description'];
$blogs->status = $input['status'];
$blogs->updated_by = access()->user()->id;
$tagsArray = $this->createTags($input['tags']);
$categoriesArray = $this->createCategories($input['categories']);
unset($input['tags'], $input['categories']);
$input['slug'] = str_slug($input['name']);
$input['publish_datetime'] = Carbon::parse($input['publish_datetime']);
$input['updated_by'] = access()->user()->id;
// Uploading Image
if (array_key_exists('featured_image', $input)) {
$this->deleteOldFile($blogs);
$this->deleteOldFile($blog);
$input = $this->uploadImage($input);
$blogs->featured_image = $input['featured_image'];
}
DB::transaction(function () use ($blogs, $input, $tagsArray, $categoriesArray) {
if ($blogs->save()) {
DB::transaction(function () use ($blog, $input, $tagsArray, $categoriesArray) {
if ($blog->update($input)) {
// Updateing associated category's id in mapper table
if (count($categoriesArray)) {
$blogs->categories()->sync($categoriesArray);
$blog->categories()->sync($categoriesArray);
}
// Updating associated tag's id in mapper table
if (count($tagsArray)) {
$blogs->tags()->sync($tagsArray);
$blog->tags()->sync($tagsArray);
}
event(new BlogUpdated($blogs));
event(new BlogUpdated($blog));
return true;
}
......@@ -147,13 +130,13 @@ class BlogsRepository extends BaseRepository
}
/**
* Creating Tags Array.
* Creating Tags.
*
* @param Array($tags)
*
* @return array
*/
public function createTagsArray($tags)
public function createTags($tags)
{
//Creating a new array for tags (newly created)
$tags_array = [];
......@@ -171,13 +154,13 @@ class BlogsRepository extends BaseRepository
}
/**
* Creating Tags Array.
* Creating Categories.
*
* @param Array($tags)
* @param Array($categories)
*
* @return array
*/
public function createCategoriesArray($categories)
public function createCategories($categories)
{
//Creating a new array for categories (newly created)
$categories_array = [];
......@@ -196,13 +179,13 @@ class BlogsRepository extends BaseRepository
}
/**
* @param Model $blog
* @param \App\Models\Blogs\Blog $blog
*
* @throws GeneralException
*
* @return bool
*/
public function delete(Model $blog)
public function delete(Blog $blog)
{
DB::transaction(function () use ($blog) {
if ($blog->delete()) {
......
......@@ -23,31 +23,27 @@ class FaqsRepository extends BaseRepository
{
return $this->query()
->select([
config('access.faqs_table').'.id',
config('access.faqs_table').'.question',
config('access.faqs_table').'.answer',
config('access.faqs_table').'.status',
config('access.faqs_table').'.created_at',
config('mdule.faqs.able').'.id',
config('odule.faqs.table').'.question',
config('module.faqs.table').'.answer',
config('module.faqs.table').'.status',
config('module.faqs.table').'.created_at',
]);
}
/**
* @param array $input
*
* @throws GeneralException
* @throws \App\Exceptions\GeneralException
*
* @return bool
*/
public function create(array $input)
{
$faq = self::MODEL;
$faq = new $faq();
$faq->question = $input['question'];
$faq->answer = $input['answer'];
$faq->status = isset($input['status']) ? $input['status'] : 0;
$input['status'] = isset($input['status']) ? 1 : 0;
//If faq saved successfully, then return true
if ($faq->save()) {
if (Faq::create($input)) {
return true;
}
......@@ -55,21 +51,19 @@ class FaqsRepository extends BaseRepository
}
/**
* @param Model $permission
* @param $input
* @param \App\Models\Faqs\Faq $faq
* @param array $input
*
* @throws GeneralException
* @throws \App\Exceptions\GeneralException
*
* return bool
*/
public function update(Model $faq, array $input)
public function update(Faq $faq, array $input)
{
$faq->question = $input['question'];
$faq->answer = $input['answer'];
$faq->status = isset($input['status']) ? $input['status'] : 0;
$input['status'] = isset($input['status']) ? 1 : 0;
//If faq updated successfully
if ($faq->save()) {
if ($faq->update($input)) {
return true;
}
......@@ -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
*/
public function delete(Model $faq)
public function delete(Faq $faq)
{
if ($faq->delete()) {
return true;
......@@ -93,14 +87,14 @@ class FaqsRepository extends BaseRepository
}
/**
* @param Model $faq
* @param $status
* @param \App\Models\Faqs\Faq $faq
* @param string $status
*
* @throws GeneralException
* @throws \App\Exceptions\GeneralException
*
* @return bool
*/
public function mark(Model $faq, $status)
public function mark(Faq $faq, $status)
{
$faq->status = $status;
......
......@@ -70,31 +70,6 @@ return [
*/
'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
*/
......
File mode changed from 100755 to 100644
......@@ -9,4 +9,16 @@ return [
'placeholders_table' => 'email_template_placeholders',
'types_table' => 'email_template_types',
],
'blog_tags' => [
'table' => 'blog_tags',
],
'blog_categories' => [
'table' => 'blog_categories',
],
'blogs' => [
'table' => 'blogs',
],
'faqs' => [
'table' => 'faqs',
],
];
......@@ -17,7 +17,7 @@
<h3 class="box-title">{{ trans('labels.backend.blogcategories.create') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.blogcategories-header-buttons')
@include('backend.blogcategories.partials.blogcategories-header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
......
......@@ -17,7 +17,7 @@
<h3 class="box-title">{{ trans('labels.backend.blogcategories.edit') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.blogcategories-header-buttons')
@include('backend.blogcategories.partials.blogcategories-header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
......
......@@ -12,7 +12,7 @@
<h3 class="box-title">{{ trans('labels.backend.blogcategories.management') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.blogcategories-header-buttons')
@include('backend.blogcategories.partials.blogcategories-header-buttons')
</div>
</div><!-- /.box-header -->
......@@ -74,10 +74,10 @@
type: 'post'
},
columns: [
{data: 'name', name: '{{config('access.blog_categories_table')}}.name'},
{data: 'status', name: '{{config('access.blog_categories_table')}}.status'},
{data: 'created_by', name: '{{config('access.blog_categories_table')}}.created_by'},
{data: 'created_at', name: '{{config('access.blog_categories_table')}}.created_at'},
{data: 'name', name: '{{config('module.blog_categories.table')}}.name'},
{data: 'status', name: '{{config('module.blog_categories.table')}}.status'},
{data: 'created_by', name: '{{config('module.blog_categories.table')}}.created_by'},
{data: 'created_at', name: '{{config('module.blog_categories.table')}}.created_at'},
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[3, "asc"]],
......
......@@ -17,7 +17,7 @@
<h3 class="box-title">{{ trans('labels.backend.blogs.create') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.blogs-header-buttons')
@include('backend.blogs.partials.blogs-header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
......
......@@ -18,7 +18,7 @@
<h3 class="box-title">{{ trans('labels.backend.blogs.edit') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.blogs-header-buttons')
@include('backend.blogs.partials.blogs-header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
......
......@@ -12,7 +12,7 @@
<h3 class="box-title">{{ trans('labels.backend.blogs.management') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.blogs-header-buttons')
@include('backend.blogs.partials.blogs-header-buttons')
</div>
</div><!-- /.box-header -->
......@@ -76,11 +76,11 @@
type: 'post'
},
columns: [
{data: 'name', name: '{{config('access.blogs_table')}}.name'},
{data: 'publish_datetime', name: '{{config('access.blogs_table')}}.publish_datetime'},
{data: 'status', name: '{{config('access.blogs_table')}}.status'},
{data: 'created_by', name: '{{config('access.blogs_table')}}.created_by'},
{data: 'created_at', name: '{{config('access.blogs_table')}}.created_at'},
{data: 'name', name: '{{config('module.blogs.table')}}.name'},
{data: 'publish_datetime', name: '{{config('module.blogs.table')}}.publish_datetime'},
{data: 'status', name: '{{config('module.blogs.table')}}.status'},
{data: 'created_by', name: '{{config('module.blogs.table')}}.created_by'},
{data: 'created_at', name: '{{config('module.blogs.table')}}.created_at'},
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[3, "asc"]],
......
......@@ -17,7 +17,7 @@
<h3 class="box-title">{{ trans('labels.backend.blogtags.create') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.blogtags-header-buttons')
@include('backend.blogtags.partials.blogtags-header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
......
......@@ -17,7 +17,7 @@
<h3 class="box-title">{{ trans('labels.backend.blogtags.edit') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.blogtags-header-buttons')
@include('backend.blogtags.partials.blogtags-header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
......
......@@ -12,7 +12,7 @@
<h3 class="box-title">{{ trans('labels.backend.blogtags.management') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.blogtags-header-buttons')
@include('backend.blogtags.partials.blogtags-header-buttons')
</div>
</div><!-- /.box-header -->
......@@ -74,10 +74,10 @@
type: 'post'
},
columns: [
{data: 'name', name: '{{config('access.blog_tags_table')}}.name'},
{data: 'status', name: '{{config('access.blog_tags_table')}}.status'},
{data: 'created_by', name: '{{config('access.blog_tags_table')}}.created_by'},
{data: 'created_at', name: '{{config('access.blog_tags_table')}}.created_at'},
{data: 'name', name: '{{config('module.blog_tags.table')}}.name'},
{data: 'status', name: '{{config('module.blog_tags.table')}}.status'},
{data: 'created_by', name: '{{config('module.blog_tags.table')}}.created_by'},
{data: 'created_at', name: '{{config('module.blog_tags.table')}}.created_at'},
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[3, "asc"]],
......
......@@ -28,4 +28,4 @@
</ul>
</div>
<div class="clearfix"></div>
<div class="clearfix"></div>
\ No newline at end of file
......@@ -10,7 +10,7 @@
@endsection
@section('content')
{{ Form::model($item, ['route' => ['admin.faqs.update', $item], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-faqs']) }}
{{ Form::model($faq, ['route' => ['admin.faqs.update', $faq], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-faqs']) }}
<div class="box box-success">
<div class="box-header with-border">
......
......@@ -21,8 +21,8 @@
<div class="col-lg-10">
<div class="control-group">
<label class="control control--checkbox">
@if(isset($item->status))
{{ Form::checkbox('status', 1, $item->status == 1 ? true :false) }}
@if(isset($faq->status))
{{ Form::checkbox('status', 1, $faq->status == 1 ? true :false) }}
@else
{{ Form::checkbox('status', 1, true) }}
@endif
......
......@@ -39,7 +39,7 @@
<a class="reset-data" href="javascript:void(0)"><i class="fa fa-times"></i></a>
</th>
<th>
{!! Form::select('status', $status, null, ["class" => "search-input-select form-control", "data-column" => 2, "placeholder" => trans('labels.backend.faqs.table.all')]) !!}
{!! Form::select('status', [1 => 'Active', 0 => 'InActive'], null, ["class" => "search-input-select form-control", "data-column" => 2, "placeholder" => trans('labels.backend.faqs.table.all')]) !!}
</th>
{{-- <th></th> --}}
<th></th>
......@@ -78,10 +78,10 @@
type: 'post'
},
columns: [
{data: 'question', name: '{{config('access.faqs_table')}}.question'},
{data: 'answer', name: '{{config('access.faqs_table')}}.answer'},
{data: 'status', name: '{{config('access.faqs_table')}}.status'},
{data: 'updated_at', name: '{{config('access.faqs_table')}}.updated_at'},
{data: 'question', name: '{{config('module.faqs.table')}}.question'},
{data: 'answer', name: '{{config('module.faqs.table')}}.answer'},
{data: 'status', name: '{{config('module.faqs.table')}}.status'},
{data: 'updated_at', name: '{{config('module.faqs.table')}}.updated_at'},
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[1, "asc"]],
......
<!--Action Button-->
@if(Active::checkUriPattern('admin/modules'))
<div class="btn-group">
<button type="button" class="btn btn-warning btn-flat dropdown-toggle" data-toggle="dropdown">Export
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li id="copyButton"><a href="#"><i class="fa fa-clone"></i> Copy</a></li>
<li id="csvButton"><a href="#"><i class="fa fa-file-text-o"></i> CSV</a></li>
<li id="excelButton"><a href="#"><i class="fa fa-file-excel-o"></i> Excel</a></li>
<li id="pdfButton"><a href="#"><i class="fa fa-file-pdf-o"></i> PDF</a></li>
<li id="printButton"><a href="#"><i class="fa fa-print"></i> Print</a></li>
</ul>
</div>
@endif
<!--Action Button-->
<div class="btn-group">
<button type="button" class="btn btn-primary btn-flat dropdown-toggle" data-toggle="dropdown">Action
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="{{route('admin.modules.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.modules.all')}}</a></li>
{{-- Will fill the permission later --}}
{{-- @permission('create-faq') --}}
<li><a href="{{route('admin.modules.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.modules.create')}}</a></li>
{{-- @endauth --}}
</ul>
</div>
<div class="clearfix"></div>
\ No newline at end of file
......@@ -17,7 +17,7 @@
<h3 class="box-title">{{ trans('labels.backend.pages.create') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.pages-header-buttons')
@include('backend.pages.partials.pages-header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
......
......@@ -17,7 +17,7 @@
<h3 class="box-title">{{ trans('labels.backend.pages.edit') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.pages-header-buttons')
@include('backend.pages.partials.pages-header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
......
......@@ -12,7 +12,7 @@
<h3 class="box-title">{{ trans('labels.backend.pages.management') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.pages-header-buttons')
@include('backend.pages.partials.pages-header-buttons')
</div>
</div><!-- /.box-header -->
......
<?php
/*
* Blogs Categories Management
*/
Route::group(['namespace' => 'BlogCategories'], function () {
Route::resource('blogcategories', 'BlogCategoriesController', ['except' => ['show']]);
//For DataTables
Route::post('blogcategories/get', 'BlogCategoriesTableController')
->name('blogcategories.get');
});
<?php
/*
* Blogs Tags Management
*/
Route::group(['namespace' => 'BlogTags'], function () {
Route::resource('blogtags', 'BlogTagsController', ['except' => ['show']]);
//For DataTables
Route::post('blogtags/get', 'BlogTagsTableController')
->name('blogtags.get');
});
<?php
/*
* Blogs Management
*/
Route::group(['namespace' => 'Blogs'], function () {
Route::resource('blogs', 'BlogsController', ['except' => ['show']]);
//For DataTables
Route::post('blogs/get', 'BlogsTableController')
->name('blogs.get');
});
......@@ -12,74 +12,3 @@ Route::post('get-permission', 'DashboardController@getPermissionByRole')->name('
Route::get('profile/edit', 'DashboardController@editProfile')->name('profile.edit');
Route::patch('profile/update', 'DashboardController@updateProfile')
->name('profile.update');
/*
* General Slug generator
*/
Route::any('generateSlug', function (\Illuminate\Http\Request $request) {
return str_slug($request['text']);
})->name('generate.slug');
/*
* Settings Management
*/
Route::group(['namespace' => 'Settings'], function () {
Route::resource('settings', 'SettingsController', ['except' => ['show', 'create', 'save', 'index', 'destroy']]);
Route::post('removeicon', 'SettingsController@removeIcon')->name('removeicon');
});
/*
* Blogs Categories Management
*/
Route::group(['namespace' => 'BlogCategories'], function () {
Route::resource('blogcategories', 'BlogCategoriesController', ['except' => ['show']]);
//For DataTables
Route::post('blogcategories/get', 'BlogCategoriesTableController')
->name('blogcategories.get');
});
/*
* Blogs Tags Management
*/
Route::group(['namespace' => 'BlogTags'], function () {
Route::resource('blogtags', 'BlogTagsController', ['except' => ['show']]);
//For DataTables
Route::post('blogtags/get', 'BlogTagsTableController')
->name('blogtags.get');
});
/*
* Blogs Management
*/
Route::group(['namespace' => 'Blogs'], function () {
Route::resource('blogs', 'BlogsController', ['except' => ['show']]);
//For DataTables
Route::post('blogs/get', 'BlogsTableController')
->name('blogs.get');
});
/*
* Faqs Management
*/
Route::group(['namespace' => 'Faqs'], function () {
Route::resource('faqs', 'FaqsController', ['except' => ['show']]);
//For DataTables
Route::post('faqs/get', 'FaqsTableController')->name('faqs.get');
// Status
Route::get('faqs/{id}/mark/{status}', 'FaqsController@mark')->name('faqs.mark')->where(['status' => '[0,1]']);
});
/*
* Notificatons Management
*/
Route::resource('notification', 'NotificationController', ['except' => ['show', 'create', 'store']]);
Route::get('notification/getlist', 'NotificationController@ajaxNotifications')->name('admin.notification.getlist');
Route::get('notification/clearcurrentnotifications', 'NotificationController@clearCurrentNotifications')->name('admin.notification.clearcurrentnotifications');
Route::group(['prefix' => 'notification/{id}', 'where' => ['id' => '[0-9]+']], function () {
Route::get('mark/{is_read}', 'NotificationController@mark')->name('admin.notification.mark')->where(['is_read' => '[0,1]']);
});
<?php
/*
* Faqs Management
*/
Route::group(['namespace' => 'Faqs'], function () {
Route::resource('faqs', 'FaqsController', ['except' => ['show']]);
//For DataTables
Route::post('faqs/get', 'FaqsTableController')->name('faqs.get');
// Status
Route::get('faqs/{faq}/mark/{status}', 'FaqStatusController@store')->name('faqs.mark')->where(['status' => '[0,1]']);
});
<?php
/*
* General Slug generator
*/
Route::any('generateSlug', function (\Illuminate\Http\Request $request) {
return str_slug($request['text']);
})->name('generate.slug');
<?php
/*
* Notificatons Management
*/
Route::resource('notification', 'NotificationController', ['except' => ['show', 'create', 'store']]);
Route::get('notification/getlist', 'NotificationController@ajaxNotifications')
->name('admin.notification.getlist');
Route::get('notification/clearcurrentnotifications', 'NotificationController@clearCurrentNotifications')
->name('admin.notification.clearcurrentnotifications');
Route::group(['prefix' => 'notification/{id}', 'where' => ['id' => '[0-9]+']], function () {
Route::get('mark/{is_read}', 'NotificationController@mark')
->name('admin.notification.mark')
->where(['is_read' => '[0,1]']);
});
<?php
/*
* Settings Management
*/
Route::group(['namespace' => 'Settings'], function () {
Route::resource('settings', 'SettingsController', ['except' => ['show', 'create', 'save', 'index', 'destroy']]);
Route::post('removeicon', 'SettingsController@removeIcon')->name('removeicon');
});
......@@ -25,7 +25,7 @@ Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], functio
// Password Reset Routes
Route::post('password/email', 'ForgotPasswordController@sendResetLinkEmail');
Route::post('password/reset', 'ResetPasswordController@reset')->name('password.reset');
// Route::post('password/reset', 'ResetPasswordController@reset')->name('password.reset');
});
// Users
......
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