Commit 124c718d authored by Vipul Basapati's avatar Vipul Basapati

BlogTag, BlogCategory, Faq Responsable Trait Implementation complete

parent b986c66b
...@@ -3,14 +3,16 @@ ...@@ -3,14 +3,16 @@
namespace App\Http\Controllers\Backend\BlogCategories; namespace App\Http\Controllers\Backend\BlogCategories;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Responses\ViewResponse;
use App\Http\Responses\RedirectResponse;
use App\Models\BlogCategories\BlogCategory;
use App\Repositories\Backend\BlogCategories\BlogCategoriesRepository;
use App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\StoreBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\CreateBlogCategoriesRequest; use App\Http\Requests\Backend\BlogCategories\CreateBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\DeleteBlogCategoriesRequest; use App\Http\Requests\Backend\BlogCategories\DeleteBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\ManageBlogCategoriesRequest; use App\Http\Requests\Backend\BlogCategories\ManageBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\StoreBlogCategoriesRequest;
use App\Http\Requests\Backend\BlogCategories\UpdateBlogCategoriesRequest; use App\Http\Requests\Backend\BlogCategories\UpdateBlogCategoriesRequest;
use App\Models\BlogCategories\BlogCategory;
use App\Repositories\Backend\BlogCategories\BlogCategoriesRepository;
/** /**
* Class BlogCategoriesController. * Class BlogCategoriesController.
...@@ -30,21 +32,21 @@ class BlogCategoriesController extends Controller ...@@ -30,21 +32,21 @@ class BlogCategoriesController extends Controller
/** /**
* @param \App\Http\Requests\Backend\BlogCategories\ManageBlogCategoriesRequest $request * @param \App\Http\Requests\Backend\BlogCategories\ManageBlogCategoriesRequest $request
* *
* @return mixed * @return ViewResponse
*/ */
public function index(ManageBlogCategoriesRequest $request) public function index(ManageBlogCategoriesRequest $request)
{ {
return view('backend.blogcategories.index'); return new ViewResponse('backend.blogcategories.index');
} }
/** /**
* @param \App\Http\Requests\Backend\BlogCategories\CreateBlogCategoriesRequest $request * @param \App\Http\Requests\Backend\BlogCategories\CreateBlogCategoriesRequest $request
* *
* @return mixed * @return \App\Http\Responses\ViewResponse
*/ */
public function create(CreateBlogCategoriesRequest $request) public function create(CreateBlogCategoriesRequest $request)
{ {
return view('backend.blogcategories.create'); return new ViewResponse('backend.blogcategories.create');
} }
/** /**
...@@ -56,9 +58,7 @@ class BlogCategoriesController extends Controller ...@@ -56,9 +58,7 @@ class BlogCategoriesController extends Controller
{ {
$this->blogcategory->create($request->all()); $this->blogcategory->create($request->all());
return redirect() return new RedirectResponse(route('admin.blogCategories.index'), ['flash_success' => trans('alerts.backend.blogcategories.created')]);
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.created'));
} }
/** /**
...@@ -69,37 +69,32 @@ class BlogCategoriesController extends Controller ...@@ -69,37 +69,32 @@ class BlogCategoriesController extends Controller
*/ */
public function edit(BlogCategory $blogCategory, EditBlogCategoriesRequest $request) public function edit(BlogCategory $blogCategory, EditBlogCategoriesRequest $request)
{ {
return view('backend.blogcategories.edit') return new EditResponse($blogCategory);
->with('blogcategory', $blogCategory);
} }
/** /**
* @param \App\Models\BlogCategories\BlogCategory $blogCategory * @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param \App\Http\Requests\Backend\BlogCategories\UpdateBlogCategoriesRequest $request * @param \App\Http\Requests\Backend\BlogCategories\UpdateBlogCategoriesRequest $request
* *
* @return mixed * @return \App\Http\Responses\RedirectResponse
*/ */
public function update(BlogCategory $blogCategory, UpdateBlogCategoriesRequest $request) public function update(BlogCategory $blogCategory, UpdateBlogCategoriesRequest $request)
{ {
$this->blogcategory->update($blogCategory, $request->all()); $this->blogcategory->update($blogCategory, $request->all());
return redirect() return new RedirectResponse(route('admin.blogCategories.index'), ['flash_success' => trans('alerts.backend.blogcategories.updated')]);
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.updated'));
} }
/** /**
* @param \App\Models\BlogCategories\BlogCategory $blogCategory * @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param \App\Http\Requests\Backend\BlogCategories\DeleteBlogCategoriesRequest $request * @param \App\Http\Requests\Backend\BlogCategories\DeleteBlogCategoriesRequest $request
* *
* @return mixed * @return \App\Http\Responses\RedirectResponse
*/ */
public function destroy(BlogCategory $blogCategory, DeleteBlogCategoriesRequest $request) public function destroy(BlogCategory $blogCategory, DeleteBlogCategoriesRequest $request)
{ {
$this->blogcategory->delete($blogCategory); $this->blogcategory->delete($blogCategory);
return redirect() return new RedirectResponse(route('admin.blogCategories.index'), ['flash_success' => trans('alerts.backend.blogcategories.deleted')]);
->route('admin.blogCategories.index')
->with('flash_success', trans('alerts.backend.blogcategories.deleted'));
} }
} }
...@@ -2,15 +2,18 @@ ...@@ -2,15 +2,18 @@
namespace App\Http\Controllers\Backend\BlogTags; namespace App\Http\Controllers\Backend\BlogTags;
use App\Models\BlogTags\BlogTag;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Responses\ViewResponse;
use App\Http\Responses\RedirectResponse;
use App\Http\Responses\Backend\BlogTag\EditResponse;
use App\Repositories\Backend\BlogTags\BlogTagsRepository;
use App\Http\Requests\Backend\BlogTags\EditBlogTagsRequest;
use App\Http\Requests\Backend\BlogTags\StoreBlogTagsRequest;
use App\Http\Requests\Backend\BlogTags\CreateBlogTagsRequest; use App\Http\Requests\Backend\BlogTags\CreateBlogTagsRequest;
use App\Http\Requests\Backend\BlogTags\DeleteBlogTagsRequest; use App\Http\Requests\Backend\BlogTags\DeleteBlogTagsRequest;
use App\Http\Requests\Backend\BlogTags\EditBlogTagsRequest;
use App\Http\Requests\Backend\BlogTags\ManageBlogTagsRequest; use App\Http\Requests\Backend\BlogTags\ManageBlogTagsRequest;
use App\Http\Requests\Backend\BlogTags\StoreBlogTagsRequest;
use App\Http\Requests\Backend\BlogTags\UpdateBlogTagsRequest; use App\Http\Requests\Backend\BlogTags\UpdateBlogTagsRequest;
use App\Models\BlogTags\BlogTag;
use App\Repositories\Backend\BlogTags\BlogTagsRepository;
/** /**
* Class BlogTagsController. * Class BlogTagsController.
...@@ -33,47 +36,44 @@ class BlogTagsController extends Controller ...@@ -33,47 +36,44 @@ class BlogTagsController extends Controller
/** /**
* @param \App\Http\Requests\Backend\BlogTags\ManageBlogTagsRequest $request * @param \App\Http\Requests\Backend\BlogTags\ManageBlogTagsRequest $request
* *
* @return mixed * @return \App\Http\Responses\ViewResponse
*/ */
public function index(ManageBlogTagsRequest $request) public function index(ManageBlogTagsRequest $request)
{ {
return view('backend.blogtags.index'); return new ViewResponse('backend.blogtags.index');
} }
/** /**
* @param \App\Http\Requests\Backend\BlogTags\CreateBlogTagsRequest $request * @param \App\Http\Requests\Backend\BlogTags\CreateBlogTagsRequest $request
* *
* @return mixed * @return \App\Http\Responses\ViewResponse
*/ */
public function create(CreateBlogTagsRequest $request) public function create(CreateBlogTagsRequest $request)
{ {
return view('backend.blogtags.create'); return new ViewResponse('backend.blogtags.create');
} }
/** /**
* @param \App\Http\Requests\Backend\BlogTags\StoreBlogTagsRequest $request * @param \App\Http\Requests\Backend\BlogTags\StoreBlogTagsRequest $request
* *
* @return mixed * @return \App\Http\Responses\RedirectResponse
*/ */
public function store(StoreBlogTagsRequest $request) public function store(StoreBlogTagsRequest $request)
{ {
$this->blogtag->create($request->except('token')); $this->blogtag->create($request->except('token'));
return redirect() return new RedirectResponse(route('admin.blogTags.index'), ['flash_success' => trans('alerts.backend.blogtags.created')]);
->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.created'));
} }
/** /**
* @param \App\Models\BlogTags\BlogTag $blogTag * @param \App\Models\BlogTags\BlogTag $blogTag
* @param \App\Http\Requests\Backend\BlogTags\EditBlogTagsRequest $request * @param \App\Http\Requests\Backend\BlogTags\EditBlogTagsRequest $request
* *
* @return mixed * @return \App\Http\Responses\Backend\BlogTag\EditResponse
*/ */
public function edit(BlogTag $blogTag, EditBlogTagsRequest $request) public function edit(BlogTag $blogTag, EditBlogTagsRequest $request)
{ {
return view('backend.blogtags.edit') return new EditResponse($blogTag);
->with('blogtag', $blogTag);
} }
/** /**
...@@ -86,9 +86,7 @@ class BlogTagsController extends Controller ...@@ -86,9 +86,7 @@ class BlogTagsController extends Controller
{ {
$this->blogtag->update($blogTag, $request->except(['_method', '_token'])); $this->blogtag->update($blogTag, $request->except(['_method', '_token']));
return redirect() return new RedirectResponse(route('admin.blogTags.index'), ['flash_success' => trans('alerts.backend.blogtags.updated')]);
->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.updated'));
} }
/** /**
...@@ -101,8 +99,6 @@ class BlogTagsController extends Controller ...@@ -101,8 +99,6 @@ class BlogTagsController extends Controller
{ {
$this->blogtag->delete($blogTag); $this->blogtag->delete($blogTag);
return redirect() return new RedirectResponse(route('admin.blogTags.index'), ['flash_success' => trans('alerts.backend.blogtags.deleted')]);
->route('admin.blogTags.index')
->with('flash_success', trans('alerts.backend.blogtags.deleted'));
} }
} }
...@@ -46,7 +46,7 @@ class BlogsController extends Controller ...@@ -46,7 +46,7 @@ class BlogsController extends Controller
/** /**
* @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request * @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request
* *
* @return mixed * @return \App\Http\Responses\Backend\Blog\IndexResponse
*/ */
public function index(ManageBlogsRequest $request) public function index(ManageBlogsRequest $request)
{ {
...@@ -69,7 +69,7 @@ class BlogsController extends Controller ...@@ -69,7 +69,7 @@ class BlogsController extends Controller
/** /**
* @param \App\Http\Requests\Backend\Blogs\StoreBlogsRequest $request * @param \App\Http\Requests\Backend\Blogs\StoreBlogsRequest $request
* *
* @return mixed * @return \App\Http\Responses\RedirectResponse
*/ */
public function store(StoreBlogsRequest $request) public function store(StoreBlogsRequest $request)
{ {
...@@ -82,7 +82,7 @@ class BlogsController extends Controller ...@@ -82,7 +82,7 @@ class BlogsController extends Controller
* @param \App\Models\Blogs\Blog $blog * @param \App\Models\Blogs\Blog $blog
* @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request * @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request
* *
* @return mixed * @return \App\Http\Responses\Backend\Blog\EditResponse
*/ */
public function edit(Blog $blog, ManageBlogsRequest $request) public function edit(Blog $blog, ManageBlogsRequest $request)
{ {
...@@ -96,7 +96,7 @@ class BlogsController extends Controller ...@@ -96,7 +96,7 @@ class BlogsController extends Controller
* @param \App\Models\Blogs\Blog $blog * @param \App\Models\Blogs\Blog $blog
* @param \App\Http\Requests\Backend\Blogs\UpdateBlogsRequest $request * @param \App\Http\Requests\Backend\Blogs\UpdateBlogsRequest $request
* *
* @return mixed * @return \App\Http\Responses\RedirectResponse
*/ */
public function update(Blog $blog, UpdateBlogsRequest $request) public function update(Blog $blog, UpdateBlogsRequest $request)
{ {
...@@ -111,7 +111,7 @@ class BlogsController extends Controller ...@@ -111,7 +111,7 @@ class BlogsController extends Controller
* @param \App\Models\Blogs\Blog $blog * @param \App\Models\Blogs\Blog $blog
* @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request * @param \App\Http\Requests\Backend\Blogs\ManageBlogsRequest $request
* *
* @return mixed * @return \App\Http\Responses\RedirectResponse
*/ */
public function destroy(Blog $blog, ManageBlogsRequest $request) public function destroy(Blog $blog, ManageBlogsRequest $request)
{ {
......
...@@ -2,18 +2,26 @@ ...@@ -2,18 +2,26 @@
namespace App\Http\Controllers\Backend\Faqs; namespace App\Http\Controllers\Backend\Faqs;
use App\Models\Faqs\Faq;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Responses\ViewResponse;
use App\Http\Responses\RedirectResponse;
use App\Http\Responses\Backend\Faq\EditResponse;
use App\Repositories\Backend\Faqs\FaqsRepository;
use App\Http\Requests\Backend\Faqs\EditFaqsRequest;
use App\Http\Requests\Backend\Faqs\StoreFaqsRequest;
use App\Http\Requests\Backend\Faqs\CreateFaqsRequest; use App\Http\Requests\Backend\Faqs\CreateFaqsRequest;
use App\Http\Requests\Backend\Faqs\DeleteFaqsRequest; use App\Http\Requests\Backend\Faqs\DeleteFaqsRequest;
use App\Http\Requests\Backend\Faqs\EditFaqsRequest;
use App\Http\Requests\Backend\Faqs\ManageFaqsRequest; use App\Http\Requests\Backend\Faqs\ManageFaqsRequest;
use App\Http\Requests\Backend\Faqs\StoreFaqsRequest;
use App\Http\Requests\Backend\Faqs\UpdateFaqsRequest; use App\Http\Requests\Backend\Faqs\UpdateFaqsRequest;
use App\Models\Faqs\Faq;
use App\Repositories\Backend\Faqs\FaqsRepository;
class FaqsController extends Controller class FaqsController extends Controller
{ {
/**
* Faq Repository
*
* @var \App\Repositories\Backend\Faqs\FaqsRepository
*/
protected $faq; protected $faq;
/** /**
...@@ -29,11 +37,11 @@ class FaqsController extends Controller ...@@ -29,11 +37,11 @@ class FaqsController extends Controller
* *
* @param \App\Http\Requests\Backend\Faqs\ManageFaqsRequest $request * @param \App\Http\Requests\Backend\Faqs\ManageFaqsRequest $request
* *
* @return \Illuminate\Http\Response * @return \App\Http\Responses\ViewResponse
*/ */
public function index(ManageFaqsRequest $request) public function index(ManageFaqsRequest $request)
{ {
return view('backend.faqs.index'); return new ViewResponse('backend.faqs.index');
} }
/** /**
...@@ -41,11 +49,11 @@ class FaqsController extends Controller ...@@ -41,11 +49,11 @@ class FaqsController extends Controller
* *
* @param \App\Http\Requests\Backend\Faqs\CreateFaqsRequest $request * @param \App\Http\Requests\Backend\Faqs\CreateFaqsRequest $request
* *
* @return \Illuminate\Http\Response * @return \App\Http\Responses\ViewResponse
*/ */
public function create(CreateFaqsRequest $request) public function create(CreateFaqsRequest $request)
{ {
return view('backend.faqs.create'); return new ViewResponse('backend.faqs.create');
} }
/** /**
...@@ -53,17 +61,13 @@ class FaqsController extends Controller ...@@ -53,17 +61,13 @@ class FaqsController extends Controller
* *
* @param \App\Http\Requests\Backend\Faqs\StoreFaqsRequest $request * @param \App\Http\Requests\Backend\Faqs\StoreFaqsRequest $request
* *
* @return \Illuminate\Http\Response * @return \App\Http\Responses\RedirectResponse
*/ */
public function store(StoreFaqsRequest $request) public function store(StoreFaqsRequest $request)
{ {
$input = $request->all(); $this->faq->create($request->all());
$this->faq->create($input);
return redirect() return new RedirectResponse(route('admin.faqs.index'), ['flash_success' => trans('alerts.backend.faqs.created')]);
->route('admin.faqs.index')
->with('flash_success', trans('alerts.backend.faqs.created'));
} }
/** /**
...@@ -72,12 +76,11 @@ class FaqsController extends Controller ...@@ -72,12 +76,11 @@ class FaqsController extends Controller
* @param \App\Models\Faqs\Faq $faq * @param \App\Models\Faqs\Faq $faq
* @param \App\Http\Requests\Backend\Faqs\EditFaqsRequest $request * @param \App\Http\Requests\Backend\Faqs\EditFaqsRequest $request
* *
* @return \Illuminate\Http\Response * @return \App\Http\Responses\Backend\Faq\EditResponse
*/ */
public function edit(Faq $faq, EditFaqsRequest $request) public function edit(Faq $faq, EditFaqsRequest $request)
{ {
return view('backend.faqs.edit') return new EditResponse($faq);
->with('faq', $faq);
} }
/** /**
...@@ -86,17 +89,13 @@ class FaqsController extends Controller ...@@ -86,17 +89,13 @@ class FaqsController extends Controller
* @param \App\Http\Requests\Backend\Faqs\UpdateFaqsRequest $request * @param \App\Http\Requests\Backend\Faqs\UpdateFaqsRequest $request
* @param \App\Models\Faqs\Faq $id * @param \App\Models\Faqs\Faq $id
* *
* @return \Illuminate\Http\Response * @return \App\Http\Responses\RedirectResponse
*/ */
public function update(UpdateFaqsRequest $request, Faq $faq) public function update(UpdateFaqsRequest $request, Faq $faq)
{ {
$input = $request->all(); $this->faq->update($faq, $request->all());
$this->faq->update($faq, $input);
return redirect() return new RedirectResponse(route('admin.faqs.index'), ['flash_success' => trans('alerts.backend.faqs.updated')]);
->route('admin.faqs.index')
->with('flash_success', trans('alerts.backend.faqs.updated'));
} }
/** /**
...@@ -105,14 +104,12 @@ class FaqsController extends Controller ...@@ -105,14 +104,12 @@ class FaqsController extends Controller
* @param \App\Models\Faqs\Faq $faq * @param \App\Models\Faqs\Faq $faq
* @param \App\Http\Requests\Backend\Faqs\DeleteFaqsRequest $request * @param \App\Http\Requests\Backend\Faqs\DeleteFaqsRequest $request
* *
* @return \Illuminate\Http\Response * @return \App\Http\Responses\RedirectResponse
*/ */
public function destroy(Faq $faq, DeleteFaqsRequest $request) public function destroy(Faq $faq, DeleteFaqsRequest $request)
{ {
$this->faq->delete($faq); $this->faq->delete($faq);
return redirect() return new RedirectResponse(route('admin.faqs.index'), ['flash_success' => trans('alerts.backend.faqs.deleted')]);
->route('admin.faqs.index')
->with('flash_success', trans('alerts.backend.faqs.deleted'));
} }
} }
<?php
namespace App\Http\Responses\Backend\Menu;
use Illuminate\Contracts\Support\Responsable;
class EditResponse implements Responsable
{
/**
* @var \App\Models\BlogCategories\BlogCategory
*/
protected $blogCategory;
/**
* @param \App\Models\BlogCategories\BlogCategory $blogCategory
*/
public function __construct($blogCategory, $types, $modules)
{
$this->blogCategory = $blogCategory;
}
/**
* toReponse
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function toResponse($request)
{
return view('backend.blogcategories.edit')
->with('blogcategory', $this->blogCategory);
}
}
<?php
namespace App\Http\Responses\Backend\BlogTag;
use Illuminate\Contracts\Support\Responsable;
class EditResponse implements Responsable
{
/**
* @var \App\Models\BlogTags\BlogTag
*/
protected $blogTag;
/**
* @param \App\Models\BlogTags\BlogTag $blogTag
*/
public function __construct($blogTag)
{
$this->blogTag = $blogTag;
}
/**
* toReponse
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function toResponse($request)
{
return view('backend.blogtags.edit')
->with('blogtag', $this->blogTag);
}
}
<?php
namespace App\Http\Responses\Backend\Faq;
use Illuminate\Contracts\Support\Responsable;
class EditResponse implements Responsable
{
/**
* @var \App\Models\Faqs\Faq
*/
protected $faq;
/**
* @param \App\Models\Faqs\Faq $faq
*/
public function __construct($faq)
{
$this->faq = $faq;
}
/**
* toReponse
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function toResponse($request)
{
return view('backend.faqs.edit')
->with('faq', $this->faq);
}
}
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