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

BlogTag, BlogCategory, Faq Responsable Trait Implementation complete

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